Esempio n. 1
0
 void dgv采购批准单_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
     {
         int id = Convert.ToInt32(dgv采购批准单["ID", e.RowIndex].Value);
         mySystem.Process.Order.采购批准单 form = new mySystem.Process.Order.采购批准单(mainform, id);
         form.Show();
     }
 }
Esempio n. 2
0
        private void btn采购批准单添加_Click(object sender, EventArgs e)
        {
            DataTable dt未批准需求单详细信息;
            Hashtable ht未批准需求单号2详细信息条数, ht未批准需求单号ID2详细信息, ht未批准需求单号2ID;

            dt未批准需求单详细信息 = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter("select * from 采购需求单详细信息 where 批准状态='未批准'", mySystem.Parameter.conn);

            da.Fill(dt未批准需求单详细信息);

            ht未批准需求单号ID2详细信息 = new Hashtable();
            ht未批准需求单号2详细信息条数 = new Hashtable();
            ht未批准需求单号2ID     = new Hashtable();
            foreach (DataRow dr in dt未批准需求单详细信息.Rows)
            {
                int id = Convert.ToInt32(dr["采购需求单ID"]);
                da = new SqlDataAdapter("select * from 采购需求单 where ID=" + id, mySystem.Parameter.conn);
                DataTable tmp = new DataTable();
                da.Fill(tmp);
                if (tmp.Rows.Count == 0)
                {
                    MessageBox.Show("采购需求单数据错误,请检查");
                    return;
                }
                String code = tmp.Rows[0]["采购申请单号"].ToString();
                if (!ht未批准需求单号2详细信息条数.ContainsKey(code))
                {
                    ht未批准需求单号2详细信息条数[code] = 0;
                }
                if (!ht未批准需求单号ID2详细信息.ContainsKey(dr["采购需求单ID"]))
                {
                    ht未批准需求单号ID2详细信息[dr["采购需求单ID"]] = new List <Object>();
                }
                if (!ht未批准需求单号2ID.ContainsKey(code))
                {
                    ht未批准需求单号2ID[code] = dr["采购需求单ID"];
                }
                ht未批准需求单号2详细信息条数[code] = Convert.ToInt32(ht未批准需求单号2详细信息条数[code]) + 1;
                ((List <Object>)ht未批准需求单号ID2详细信息[dr["采购需求单ID"]]).Add(dr["存货代码"].ToString() + "," + dr["存货名称"].ToString() + "," + dr["规格型号"].ToString());
            }
            DataTable dt = new DataTable();

            dt.Columns.Add("ID", Type.GetType("System.Int32"));
            dt.Columns.Add("采购申请单号", Type.GetType("System.String"));
            dt.Columns.Add("未批准项目数量", Type.GetType("System.Int32"));
            foreach (string code in ht未批准需求单号2详细信息条数.Keys.OfType <string>().ToArray <string>())
            {
                DataRow dr = dt.NewRow();
                dr["ID"]      = ht未批准需求单号2ID[code];
                dr["采购申请单号"]  = code;
                dr["未批准项目数量"] = ht未批准需求单号2详细信息条数[code];
                dt.Rows.Add(dr);
            }
            try
            {
                string ids = mySystem.Other.InputDataGridView.getIDs("", dt, true, ht未批准需求单号ID2详细信息);
                if (ids == "")
                {
                    return;
                }
                mySystem.Process.Order.采购批准单 form = new mySystem.Process.Order.采购批准单(mainform, ids);
                form.Show();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message + "\n" + ee.StackTrace);
            }
        }