Exemple #1
0
 /// <summary>
 /// 控制申请数量只能填写数字
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgv1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         int i = e.ColumnIndex;
         DataGridViewColumn column = dgv1.Columns[e.ColumnIndex];
         if (column.Name == "申请数量")
         {
             if (dgv1.Rows[e.RowIndex].Cells[i].Value != null)
             {
                 string rqty = dgv1.Rows[e.RowIndex].Cells[i].Value.ToString();
                 if (BaseClass.validateNum(rqty) == false)
                 {
                     MessageBox.Show("请输入数字!!!", "提示");
                     dgv1.Rows[e.RowIndex].Cells[i].Value = "";
                 }
             }
         }
         else if (column.Name == "零件号")
         {
             if (dgv1.Rows[e.RowIndex].Cells[i].Value != null)
             {
                 string        rqty       = dgv1.Rows[e.RowIndex].Cells[i].Value.ToString();
                 string        Site       = cmb_site.SelectedValue.ToString();
                 InventoryPart invpartnew = InventoryPart.FindInvInfor(rqty, Site);
                 if (invpartnew != null)
                 {
                     dgv1.Rows[e.RowIndex].Cells[i].Value     = invpartnew.PART_NO;
                     dgv1.Rows[e.RowIndex].Cells[i + 1].Value = invpartnew.description;
                     dgv1.Rows[e.RowIndex].Cells["单位"].Value  = invpartnew.unit_meas;
                 }
                 else
                 {
                     MessageBox.Show("无此材料编码");
                     return;
                 }
                 InventoryPart invpart = InventoryPart.GetOnhandqty(Site, rqty, ProjectId);
                 if (invpart != null)
                 {
                     dgv1.Rows[e.RowIndex].Cells["inventory_qty"].Value = invpart.qty_onhand;
                     dgv1.Rows[e.RowIndex].Cells["JYstock"].Value       = invpart.qty_reserved;
                     dgv1.Rows[e.RowIndex].Cells["meo_qty"].Value       = Convert.ToDecimal(invpart.qty_onhand) - Convert.ToDecimal(invpart.qty_reserved);
                 }
             }
         }
     }
 }
Exemple #2
0
        public void listviewBind(string sql)
        {
            //更改并设置列名称以及属性
            DataSet ds = PartParameter.QueryPartPara(sql);

            dgv1.DataSource = ds.Tables[0];
            //DataGridViewComboBoxColumn dgvcom = new DataGridViewComboBoxColumn();
            //dgvcom.DataSource = PartParameter.QueryPartPara("select name from mm_unit_tab").Tables[0].DefaultView;;
            //dgvcom.DisplayMember = "name";
            //dgvcom.ValueMember = "name";
            ////dgv1.Columns.Insert(1, dgvcom);
            //dgv1.GridColumnStyles[1]=dgvcom;
            //dgv1.Columns["零件认证"].Width = 100;
            //dgv1.Columns["单位密度"].ValueType = typeof();
            //dgv1.Columns["零件材质"].ValueType = typeof(float);
            dgv1.Columns["域"].ReadOnly   = true;
            dgv1.Columns["序号"].ReadOnly  = true;
            dgv1.Columns["零件号"].ReadOnly = true;
            //dgv1.Columns["零件类别"].ReadOnly = true;
            //dgv1.Columns["零件规格"].ReadOnly = true;
            //dgv1.Columns["材质"].ReadOnly = true;
            //dgv1.Columns["证书"].ReadOnly = true;
            //dgv1.Columns["单位"].ReadOnly = true;

            dgv1.Columns["parentid"].Visible = false;
            #region 将库存值填入表格
            if (cb_showqty.Checked == true)
            {
                dgv1.Columns["项目预留数量"].ReadOnly  = true;
                dgv1.Columns["项目采购数量"].ReadOnly  = true;
                dgv1.Columns["项目可用库存量"].ReadOnly = true;
                if (dgv1.RowCount != 0)
                {
                    ProjectCmbItem item = (ProjectCmbItem)cmb_project.SelectedItem;
                    if (item == null)
                    {
                        MessageBox.Show("请选择所查询的项目");
                        return;
                    }
                    string projectname = item.Value;

                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        string        partno     = dgv1.Rows[i].Cells["零件号"].Value.ToString();
                        InventoryPart part_kucun = InventoryPart.GetOnhandqty(site, partno, projectname.Substring(projectname.Length - 3, 3));;
                        if (part_kucun != null)
                        {
                            dgv1.Rows[i].Cells["项目可用库存量"].Value = part_kucun.qty_onhand;
                            dgv1.Rows[i].Cells["项目采购数量"].Value  = Convert.ToDecimal(part_kucun.qty_onhand) - Convert.ToDecimal(part_kucun.qty_reserved);
                            dgv1.Rows[i].Cells["项目预留数量"].Value  = part_kucun.qty_reserved;
                        }
                        else
                        {
                            dgv1.Rows[i].Cells["预估量"].Value = 0;
                            //dgv1.Rows[i].Cells[2].Value = "M";
                        }
                    }
                    //}
                }
            }
            #endregion

            //#region 设置列的只读性
            //int specnum = PartParameter.GetSpecCou(activity);
            //if (specnum != 0)
            //{
            //    if (specnum > 0)
            //    {
            //        string colstr = PartParameter.GetSpecName(activity, "1").Trim();
            //        dgv1.Columns[colstr].ReadOnly = true;
            //    }
            //    if (specnum > 1)
            //    {
            //        string colstr = PartParameter.GetSpecName(activity, "2").Trim();
            //        dgv1.Columns[colstr].ReadOnly = true;
            //    }
            //    if (specnum > 2)
            //    {
            //        string colstr = PartParameter.GetSpecName(activity, "3").Trim();
            //        dgv1.Columns[colstr].ReadOnly = true;
            //    }
            //    if (specnum > 3)
            //    {
            //        string colstr = PartParameter.GetSpecName(activity, "4").Trim();
            //        dgv1.Columns[colstr].ReadOnly = true;
            //    }
            //}
            //#endregion

            #region 将已设置过的预估值填入表格
            //if (dgv1.RowCount != 0)
            //{
            //    List<PartParameter> pp = PartParameter.FindPartList(activity, ProjectId,LoginUser,1);
            //    //if (pp.Count != 0)
            //    // {
            //    for (int i = 0; i < dgv1.Rows.Count; i++)
            //    {

            //        int partid = int.Parse(dgv1.Rows[i].Cells["序号"].Value.ToString());
            //        PartParameter pone = pp.Find(delegate(PartParameter bb) { return bb.ID == partid; });
            //        if (pone != null)
            //        {
            //            dgv1.Rows[i].Cells["预估量"].Value = pone.PREDICTION_QTY;
            //            //dgv1.Rows[i].Cells[2].Value = pone.UNIT;
            //        }
            //        else
            //        {
            //            dgv1.Rows[i].Cells["预估量"].Value = 0;
            //            //dgv1.Rows[i].Cells[2].Value = "M";
            //        }

            //    }
            //    //}
            //}
            #endregion
        }