Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            frmSelectDataDialog frmselect = new frmSelectDataDialog("Emp", "");

            frmselect.frmSeorderPlanEdit = this;                    //将新创建的窗体对象设置为同一个窗体类的实例(对象)
            frmselect.frmName            = "frmSeorderPlanEdit";    //用于识别 是那一个窗体调用的select窗口的
            frmselect.ShowDialog();
        }
Пример #2
0
        private void txtFEmpNumber_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (this.FCustID == null)
                {
                    ds = k3db.GetDataSet("  SELECT FItemID, FNumber 代码,FName 名称,FAddress 地址 FROM dbo.t_emp WHERE FDeleted=0 and fnumber like '%" + this.txtFEmpNumber.Text + "%'    ", "tab");
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        this.FEmpID             = ds.Tables[0].Rows[0][0].ToString();
                        this.txtFEmpNumber.Text = ds.Tables[0].Rows[0][2].ToString();
                    }
                    else
                    {
                        frmSelectDataDialog frmselect = new frmSelectDataDialog("Emp", this.txtFEmpNumber.Text);

                        frmselect.frmSeorderPlanEdit = this;                    //将新创建的窗体对象设置为同一个窗体类的实例(对象)
                        frmselect.frmName            = "frmSeorderPlanEdit";    //用于识别 是那一个窗体调用的select窗口的
                        frmselect.ShowDialog();
                    }
                }
            }
        }
Пример #3
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {//双击
            if (e.ColumnIndex == 1)
            {
                // MessageBox.Show("1111"); .Value
                string fnumber;
                if (dataGridView1["ColumnFitemNnmber", e.RowIndex].Value == null)
                {
                    fnumber = "";
                }
                else
                {
                    fnumber = dataGridView1["ColumnFitemNnmber", e.RowIndex].Value.ToString();
                }
                frmSelectDataDialog frmselect = new frmSelectDataDialog("Icitem", fnumber);

                frmselect.frmSeorderPlanEdit = this;                    //将新创建的窗体对象设置为同一个窗体类的实例(对象)
                frmselect.frmName            = "frmSeorderPlanEdit";    //用于识别 是那一个窗体调用的select窗口的
                frmselect.M_int_CurrentRow = e.RowIndex;
                frmselect.ShowDialog();
                this.dataGridView1.CurrentCell = dataGridView1["ColumnFSFQty", e.RowIndex]; //设置辅助重量单元格获得焦点
                dataGridView1.BeginEdit(true);
            }
        }
Пример #4
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {//
            if (e.ColumnIndex == 1 && e.RowIndex >= 0 && this.dataGridView1["ColumnFitemID", e.RowIndex].Value == null)
            {
                                                                                                                       //产品代码单元格变化
                {
                    // this.dataGridView1.AllowUserToAddRows = false;
                    string fnumber;
                    int    row;

                    row = this.dataGridView1.CurrentCell.RowIndex;//行
                    if (this.dataGridView1["ColumnFitemNnmber", row].Value == null)
                    {
                        fnumber = "";
                    }
                    else
                    {
                        fnumber = this.dataGridView1["ColumnFitemNnmber", row].Value.ToString();
                    }

                    ds = db.GetDataSet(" SELECT FItemID ,fnumber  代码,FName 名称,fmodel 规格型号,FUnitID FKUnitID,funitname k3单位,FSecUnitname 辅助单位,FSecCoefficient 换算率 FROM dbo.rysp_icitem  where Fdelete=0 and fnumber like '%" + fnumber + "%'    ", "tab");
                    if (ds.Tables[0].Rows.Count == 1)
                    {                                                                                                 //如果输入的代码只有一个产品直接赋值
                        this.dataGridView1["ColumnFitemID", row].Value         = ds.Tables[0].Rows[0][0].ToString();; // finterid
                        this.dataGridView1["ColumnFitemNnmber", row].Value     = ds.Tables[0].Rows[0][1].ToString();; //fnumber
                        this.dataGridView1["ColumnFitemName", row].Value       = ds.Tables[0].Rows[0][2].ToString();; //fname
                        this.dataGridView1["ColumnFmodel", row].Value          = ds.Tables[0].Rows[0][3].ToString();; //fmodel
                        this.dataGridView1["ColumnFKUnitID", row].Value        = ds.Tables[0].Rows[0][4].ToString();; //FKUnitID
                        this.dataGridView1["ColumnFKUnitName", row].Value      = ds.Tables[0].Rows[0][5].ToString();; //funitname
                        this.dataGridView1["ColumnFFUnitName", row].Value      = ds.Tables[0].Rows[0][6].ToString();  //FSecUnitname
                        this.dataGridView1["ColumnFSecCoefficient", row].Value = ds.Tables[0].Rows[0][7].ToString();  //FSecCoefficient
                        this.dataGridView1.CurrentCell = dataGridView1["ColumnFSFQty", e.RowIndex];                   //设置辅助重量单元格获得焦点
                        dataGridView1.BeginEdit(true);
                    }
                    else
                    {//否则弹出查询窗体
                        frmSelectDataDialog frmselect = new frmSelectDataDialog("Icitem", fnumber);

                        frmselect.frmSeorderPlanEdit = this;                    //将新创建的窗体对象设置为同一个窗体类的实例(对象)
                        frmselect.frmName            = "frmSeorderPlanEdit";    //用于识别 是那一个窗体调用的select窗口的
                        frmselect.M_int_CurrentRow = this.dataGridView1.CurrentCell.RowIndex;
                        frmselect.ShowDialog();
                        //this.dataGridView1.CurrentCell = dataGridView1["ColumnFSFQty", e.RowIndex]; //设置辅助重量单元格获得焦点
                        //dataGridView1.BeginEdit(true);
                    }
                }
            }

            if (e.ColumnIndex == 0 && e.RowIndex >= 0)
            {//取得产品内码时 通过内码去获取单价
                if (this.dataGridView1["ColumnFitemID", e.RowIndex].Value != null)
                {
                    SqlParameter param1 = new SqlParameter("@ItemID", SqlDbType.Int);
                    param1.Value = int.Parse(this.dataGridView1["ColumnFitemID", e.RowIndex].Value.ToString());
                    SqlParameter param2 = new SqlParameter("@fcurid", SqlDbType.Int);
                    param2.Value = int.Parse(this.FCustID);
                    //创建泛型
                    List <SqlParameter> parameters = new List <SqlParameter>();
                    parameters.Add(param1);
                    parameters.Add(param2);
                    //把泛型中的元素复制到数组中
                    SqlParameter[] inputParameters = parameters.ToArray();

                    DataTable dt = db.GetDataTable("sp_getPrice", inputParameters);
                    if (dt.Rows.Count == 0)
                    {
                        MessageBox.Show("未能获得K3中的单价,请先到K3主控台维护单价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.dataGridView1["ColumnFPrice", e.RowIndex].Value = "";
                    }
                    else
                    {
                        this.dataGridView1["ColumnFPrice", e.RowIndex].Value = dt.Rows[0][0].ToString();
                    }
                }
            }

            if (e.ColumnIndex == 9 && e.RowIndex >= 0)
            {//更改k3重量
                try
                {
                    this.dataGridView1["ColumnFSFQty", e.RowIndex].Value =
                        (Convert.ToSingle(this.dataGridView1["ColumnFSkQty", e.RowIndex].Value.ToString()) /
                         Convert.ToSingle(this.dataGridView1["ColumnFSecCoefficient", e.RowIndex].Value.ToString())).ToString();
                }
                catch {
                    MessageBox.Show("重量录入非法字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                try
                {
                    //计算当前行金额
                    this.dataGridView1["ColumnFSAmount", e.RowIndex].Value = Convert.ToSingle
                                                                                 ((Convert.ToSingle(this.dataGridView1["ColumnFSkQty", e.RowIndex].Value.ToString()) *
                                                                                   Convert.ToSingle(this.dataGridView1["ColumnFPrice", e.RowIndex].Value.ToString()))).ToString();
                    //计算合计金额
                    try
                    {
                        float Sumfamout = 0;
                        for (int i = 0; i <= dataGridView1.RowCount; i++)
                        {
                            Sumfamout = Sumfamout + Convert.ToSingle(dataGridView1["ColumnFSAmount", i].Value.ToString());

                            this.txtSumFamout.Text = Sumfamout.ToString();
                        }
                    }
                    catch { }


                    //添加一行
                    this.dataGridView1.Rows.Add();
                }
                catch
                {
                    MessageBox.Show("重量或单价错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            if (e.ColumnIndex == 10 && e.RowIndex >= 0)
            {//更改辅助重量
                try
                {
                    this.dataGridView1["ColumnFSkQty", e.RowIndex].Value =
                        (Convert.ToSingle(this.dataGridView1["ColumnFSFQty", e.RowIndex].Value.ToString()) *
                         Convert.ToSingle(this.dataGridView1["ColumnFSecCoefficient", e.RowIndex].Value.ToString())).ToString();
                }
                catch
                {
                    MessageBox.Show("重量录入非法字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }