| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 356 人关注过本帖
标题:求帮忙,解释C#部分代码
只看楼主 加入收藏
aaa258521
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-5-12
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求帮忙,解释C#部分代码
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace yaopinguanli.sale
{
    public partial class 销售 : Form
    {
        public 销售()
        {
            InitializeComponent();
        }

        private void xiaoshou_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt = ClassInfo.DataBase.sel("select * from M_saleListSum");
            int b;
            b = dt.Rows.Count + 1;
            txtsalecode.Text = "s00" + b.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtCustomname.Text == string.Empty || txtEname.Text == string.Empty)
            {
                MessageBox.Show("经办人和客户名称不能为空!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Hashtable sqls = new Hashtable();
                for (int i = 0; i < salelistView.RowCount - 1; i++)
                {
                    sqls.Add(2 + i, "insert into M_saleList values('" + txtsalecode.Text.Trim() + "','" + salelistView.Rows[i].Cells[0].Value.ToString() + "','" + salelistView[1, i].Value.ToString() + "','" + salelistView.Rows[i].Cells[2].Value.ToString() + "','" + salelistView.Rows[i].Cells[3].Value.ToString() + "','" + salelistView.Rows[i].Cells[4].Value.ToString() + "','" + salelistView.Rows[i].Cells[5].Value.ToString() + "')");
                }
                sqls.Add(1, "insert into M_saleListSum values('" + txtsalecode.Text.Trim() + "','" + txtEname.Text.Trim() + "','" + txtS_time.Text.Trim() + "','" + txtCustomname.Text.Trim() + "','" + txtS_sum.Text.Trim() + "','" + txtS_Ypay.Text.Trim() + "','" + txtS_spay.Text.Trim() + "','" + txt_S_chae.Text.Trim() + "')");
                //if (db.DoTrans.DoManyTran(sqls))
                if (ClassInfo.DataBase.Domanytran(sqls))
                    MessageBox.Show("保存成功!");
                else MessageBox.Show("保存失败!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);//  总是保存失败,咋回事,是代码问题吗?求高手赐教!
            }

        }

        private void label10_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            yaopinguanli.储存表.handed selectedHD;
            selectedHD = new yaopinguanli.储存表.handed();
            selectedHD.sl = this;
            selectedHD.selected = "sale";
            selectedHD.ShowDialog();

        }

        private void button4_Click(object sender, EventArgs e)
        {
            yaopinguanli.储存表.customed selectedCN;
            selectedCN = new yaopinguanli.储存表.customed(this);
            selectedCN.ShowDialog();
        }



        private void salelistView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void salelistView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            yaopinguanli.储存表.yaopin selectYP = new yaopinguanli.储存表.yaopin(this);
            selectYP.ShowDialog();
        }

        private void txtS_Ypay_TextChanged(object sender, EventArgs e)
        {

        }

        private void salelistView_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e)
        {
            try
            {
                float s_sum = 0;//总数量
                float Y_money = 0;//应收金额
                for (int n = 0; n <= salelistView.RowCount; n++)
                {
                    s_sum = s_sum + Convert.ToSingle(salelistView[4, n].Value.ToString());
                    Y_money = Y_money + Convert.ToSingle(salelistView[5, n].Value.ToString());
                    txtS_Ypay.Text = Y_money.ToString();
                    txtS_sum.Text = s_sum.ToString();
                }
            }
            catch { }
        }

        private void salelistView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {

            if (e.ColumnIndex == 3)
            {
                try
                {
                    float M_sum;//金额
                    M_sum = Convert.ToSingle(salelistView[3, e.RowIndex].Value.ToString()) * Convert.ToSingle(salelistView[4, e.RowIndex].Value.ToString());
                    salelistView[5, e.RowIndex].Value = M_sum.ToString();
                }
                catch { }
            }
            if (e.ColumnIndex == 4)
            {
                try
                {
                    float M_sum;//金额
                    M_sum = Convert.ToSingle(salelistView[3, e.RowIndex].Value.ToString()) * Convert.ToSingle(salelistView[4, e.RowIndex].Value.ToString());
                    salelistView[5, e.RowIndex].Value = M_sum.ToString();
                }
                catch { }
            }
        }



        private void txtS_spay_TextChanged(object sender, EventArgs e)
        {
            try
            {
                txt_S_chae.Text = Convert.ToString(Convert.ToSingle(txtS_spay.Text) - Convert.ToSingle(txtS_Ypay.Text));
            }
            catch { }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }


    }
}
搜索更多相关主题的帖子: 销售 private public 
2012-05-12 15:32
zwffff
Rank: 4
等 级:业余侠客
威 望:1
帖 子:58
专家分:224
注 册:2007-11-13
收藏
得分:20 
其他相关代码都看不到,很难告诉你哪里有问题的?既然保存失败,肯定是ClassInfo.DataBase.Domanytran(sqls)这句执行的问题。但是你这句相关的代码都看不到,怎么帮你找问题呢?

欢迎加入.Net技术交流群:90925122
2012-05-17 14:47
快速回复:求帮忙,解释C#部分代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026783 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved