public void listviewBindpara(string sql)
        {
            //更改并设置列名称以及属性
            dgv1.AutoGenerateColumns = false;
            ds = PartParameter.QueryPartPara(sql);
            dgv1.DataSource = ds.Tables[0].DefaultView;

            //DataGridViewComboBoxColumn dgvcom = new DataGridViewComboBoxColumn();
            //DataSet blockds = PartParameter.QueryPartPara("select block_id,description from project_block_tab where project_id=" + ecprojectid.ToString() + " order by description");
            //DataRow rowdim = blockds.Tables[0].NewRow();
            //rowdim[0] = 1;
            //blockds.Tables[0].Rows.InsertAt(rowdim, 0);
            //dgvcom.DataSource = blockds.Tables[0].DefaultView;
            //dgvcom.DisplayMember = "description";
            //dgvcom.ValueMember = "description";
            //dgvcom.HeaderText = "分段";
            //dgvcom.Name = "分段";
            //dgvcom.ReadOnly = false;
            //CalendarColumn dgvcal = new CalendarColumn();
            //dgvcal.HeaderText = "预估日期";
            //dgvcal.Name = "预估日期";

            ////DateColumn dgvcaln = new DateColumn();
            ////dgvcaln.HeaderText = "日期新";
            //if (!dgv1.Columns.Contains("预估日期"))
            //{
            //    //dgv1.Columns.Add(dgvcom);
            //    dgv1.Columns.Add(dgvcal);
            //    //dgv1.Columns.Add(dgvcaln);
            //    dgv1.Columns["预估日期"].Width = 200;
            //}
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string sqlSelect = " order by t.createdate";

            //string wheresql = sb.ToString();
            ds = PartParameter.QueryPartPara(sqlSelect);
            dgv1.DataSource = ds.Tables[0];
            SetrowStyle();
        }
Beispiel #3
0
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            string fdate = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
            //DateTime tdate =  Convert.ToDateTime(this.dateTimePicker1.Value.AddDays(1).ToString("yyyy-MM-dd"));
            string datesr    = "to_char(createdate,'yyyy-mm-dd')='" + fdate + "'";
            string sqlSelect = " order by t.createdate";

            ds = PartParameter.QueryPartPara(sqlSelect);
            dgv1.DataSource = ds.Tables[0];
            SetrowStyle();
        }
Beispiel #4
0
        private void frmPartInventory_Load(object sender, EventArgs e)
        {
            ProjectCmbBind();

            partnocmb = this.cmb_partno;
            //MessageBox.Show(site);
            DataSet unitds = PartParameter.QueryPartPara("select name from mm_unit_tab");

            SiteCmbBind();
            //GridViewTitleBind();
        }
        /// <summary>
        /// 对ComboBox控件进行数据绑定
        /// </summary>
        /// <param name="M_str_sqlstr">SQL语句</param>
        /// <param name="M_str_table">表名</param>
        /// <param name="M_str_tbMember">数据表中字段名</param>
        /// <param name="cbox">ComboBox控件ID</param>
        public static void cboxBind(string M_str_sqlstr, string M_str_tbValue, string M_str_tbMember, ComboBox cbox)
        {
            DataSet myds   = PartParameter.QueryPartPara(M_str_sqlstr);
            DataRow rowdim = myds.Tables[0].NewRow();

            rowdim[0] = 0;
            myds.Tables[0].Rows.InsertAt(rowdim, 0);
            cbox.DataSource    = myds.Tables[0].DefaultView;
            cbox.DisplayMember = M_str_tbMember;
            cbox.ValueMember   = M_str_tbValue;
        }
Beispiel #6
0
        private void frmParaLog_Load(object sender, EventArgs e)
        {
            //StringBuilder sb = new StringBuilder();

            //string spec_namestr = PartParameter.GetSpecName(activity);
            string sqlSelect = "SELECT * from MM_PART_PARAMETER_TAB where projectid='" + ProjectId + "' and part_no=" + Part_No + "  and discipline =" + DisciplineId + "order by createdate";;

            //string wheresql = sb.ToString();
            ds = PartParameter.QueryPartPara(sqlSelect);
            dgv1.DataSource = ds.Tables[0].DefaultView;
            SetrowStyle();
        }
Beispiel #7
0
        private void frmPartAdd_Load(object sender, EventArgs e)
        {
            ProjectCmbBind();
            AddMaterialTree();
            partnocmb = this.cmb_partno;
            //MessageBox.Show(site);
            DataSet unitds = PartParameter.QueryPartPara("select name from mm_unit_tab");

            tb_unit.DataSource    = unitds.Tables[0].DefaultView;
            tb_unit.DisplayMember = "name";
            tb_unit.ValueMember   = "name";
            SiteCmbBind();
            //GridViewTitleBind();
            gboxheight = btn_del.Top;
        }
Beispiel #8
0
        private void button4_Click(object sender, EventArgs e)
        {
            string site            = cmb_site.SelectedValue.ToString();
            string partno          = cmb_partno.Text.Trim().ToString();
            string partspec        = cmb_partname.Text.Trim().ToString();
            string parttype        = tb_type.Text.Trim().ToString();
            string partmat         = tb_mat.Text.Trim().ToString();
            string partlevel       = tb_level.Text.Trim().ToString();
            string partcert        = tb_cert.Text.Trim().ToString();
            string purchasec       = tb_pc.Text.Trim().ToString();
            string spec1           = tb_spec1.Text.Trim().ToString();
            string spec2           = tb_spec2.Text.Trim().ToString();
            string spec3           = tb_spec3.Text.Trim().ToString();
            string spec4           = tb_spec4.Text.Trim().ToString();
            string partunit        = tb_unit.Text.Trim().ToString();
            string partunitdestiny = tb_unitdestiny.Text.Trim().ToString();
            string partdestinyunit = txt_destinyunit.Text.Trim().ToString();

            //if (ProjectId == string.Empty)
            //{
            //    MessageBox.Show("请选择项目!");
            //    return;
            //}
            if (partno == string.Empty)
            {
                MessageBox.Show("请填写零件编号!");
                return;
            }
            if (Part.Exist(partno))
            {
                MessageBox.Show("此零件编号已经存在,请检查!");
                return;
            }
            if (partspec == string.Empty)
            {
                MessageBox.Show("请填写零件规格!");
                return;
            }
            if (parttype == string.Empty)
            {
                MessageBox.Show("请填写零件类型!");
                return;
            }
            if (partmat == string.Empty)
            {
                MessageBox.Show("请填写零件材质!");
                return;
            }
            if (partcert == string.Empty)
            {
                MessageBox.Show("请填写零件证书!");
                return;
            }
            if (partlevel == string.Empty)
            {
                MessageBox.Show("请填写零件等级!");
                return;
            }
            try
            {
                DataSet unitds = PartParameter.QueryPartPara("select name from mm_unit_tab");
                //string partno = dgv1.Rows[i].Cells["零件号"].Value.ToString().Trim();
                //PartParameter pp = PartParameter.Find(ProjectId, partno, site, LoginUser);
                Part ppn = new Part();
                ppn.PART_NO   = partno;
                ppn.CONTRACT  = site;
                ppn.PARENTID  = int.Parse(activity);
                ppn.PART_CERT = partcert;
                if (partunitdestiny != string.Empty)
                {
                    ppn.PART_UNITDENSITY = decimal.Parse(partunitdestiny);
                }
                if (partdestinyunit != string.Empty)
                {
                    ppn.PART_DENSITYUNIT = partdestinyunit;
                }
                ppn.PART_LEVEL = partlevel;
                ppn.PART_SPEC  = partspec;
                ppn.PART_SPEC1 = spec1;
                ppn.PART_SPEC2 = spec2;
                ppn.PART_SPEC3 = spec3;
                ppn.PART_SPEC4 = spec4;
                ppn.CREATOR    = LoginUser;
                ppn.PART_UNIT  = partunit;
                ppn.PART_MAT   = partmat;
                ppn.PART_TYPE  = parttype;
                if (purchasec != string.Empty)
                {
                    ppn.SUPPLYCIRCLE = int.Parse(purchasec);
                }
                else
                {
                    ppn.SUPPLYCIRCLE = 10;
                }
                #region 判断Unit是否是合格格式

                DataRow[] pone = unitds.Tables[0].Select("name ='" + partunit + "'");
                if (pone.Length != 0)
                {
                    ppn.PART_UNIT = partunit;
                }
                else
                {
                    MessageBox.Show("单位名称不规范,请检查!", "错误提示");
                    tb_unit.Focus();
                    return;
                }

                #endregion
                int count = ppn.Add();
                if (count == 0)
                {
                    MessageBox.Show("添加失败");
                    return;
                }
                MessageBox.Show("保存零件成功!! ", "温馨提示!");
                QuerydataBind();
                #region
                //int cou = PartParameter.GetSpecCou(activity);
                //DataGridViewRow newrow = new DataGridViewRow();
                //dgv1.Rows.Insert(0, newrow);

                //newrow.CreateCells(dgv1);
                //newrow.Cells[11 + cou].Value = site;
                //if (cou > 0)
                //{
                //    newrow.Cells[4].Value = spec1;
                //}
                //if (cou > 1)
                //{
                //    newrow.Cells[5].Value = spec2;
                //}
                //if (cou > 2)
                //{
                //    newrow.Cells[6].Value = spec3;
                //}
                //if (cou > 3)
                //{
                //    newrow.Cells[7].Value = spec4;
                //}

                //newrow.Cells[2].Value = parttype;
                //newrow.Cells[3].Value = partspec;
                //newrow.Cells[4+cou].Value = partmat;
                //newrow.Cells[5 + cou].Value = partcert;
                //newrow.Cells[6 + cou].Value = partunit;
                ////newrow.Cells["密度单位"].Value = partunit;
                //newrow.Cells[9 + cou].Value = partlevel;
                //newrow.Cells[7 + cou].Value = partunitdestiny;
                //newrow.Cells[10 + cou].Value = activity;
                //dgv1.Rows.Add(newrow);
                #endregion
            }
            catch (Exception err)
            {
                MessageBox.Show("错误原因:" + err.Message, "错误提示信息",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #9
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            //string projectid = cmb_project.SelectedValue.ToString();

            if (ProjectId == string.Empty)
            {
                MessageBox.Show("请选择项目!");
                return;
            }
            if (dgv1.RowCount == 0)
            {
                MessageBox.Show("请选择数据!");
                return;
            }
            string site = cmb_site.SelectedValue.ToString();
            int    kqrow;

            kqrow = dgv1.RowCount - 1;
            try
            {
                DataSet unitds = PartParameter.QueryPartPara("select name from mm_unit_tab");
                #region 循环表,保存数据
                for (int i = 0; i <= kqrow; i++)
                {
                    string partno = dgv1.Rows[i].Cells["零件号"].Value.ToString().Trim();
                    int    partid = int.Parse(dgv1.Rows[i].Cells["序号"].Value.ToString());
                    if (Part.Exist(partno, partid))
                    {
                        MessageBox.Show("第" + partid.ToString() + "行编码重复,请检查!");
                        return;
                    }
                    Part   ppn = new Part();
                    string partspec = dgv1.Rows[i].Cells["零件规格"].Value.ToString().Trim();
                    string parttype = dgv1.Rows[i].Cells["零件类别"].Value.ToString().Trim();
                    string partmat = dgv1.Rows[i].Cells["材质"].Value.ToString().Trim();
                    string partlevel = dgv1.Rows[i].Cells["等级"].Value.ToString().Trim();
                    string partcert = dgv1.Rows[i].Cells["证书"].Value.ToString().Trim();
                    string partpurchase = dgv1.Rows[i].Cells["采购周期"].Value.ToString().Trim();
                    string destinyunit = dgv1.Rows[i].Cells["密度单位"].Value.ToString().Trim();
                    string replacecode = dgv1.Rows[i].Cells["替代码"].Value.ToString().Trim();
                    string spec1 = "", spec2 = "", spec3 = "", spec4 = "";
                    if (lspec1.Visible == true)
                    {
                        spec1 = dgv1.Rows[i].Cells[lspec1.Text].Value.ToString().Trim();
                    }
                    if (lspec2.Visible == true)
                    {
                        spec2 = dgv1.Rows[i].Cells[lspec2.Text].Value.ToString().Trim();
                    }
                    if (lspec3.Visible == true)
                    {
                        spec3 = dgv1.Rows[i].Cells[lspec3.Text].Value.ToString().Trim();
                    }
                    if (lspec4.Visible == true)
                    {
                        spec4 = dgv1.Rows[i].Cells[lspec4.Text].Value.ToString().Trim();
                    }
                    string partunit        = dgv1.Rows[i].Cells["单位"].Value.ToString().Trim();
                    string partunitdestiny = dgv1.Rows[i].Cells["单位密度"].Value.ToString().Trim();
                    ppn.PART_NO   = partno;
                    ppn.CONTRACT  = site;
                    ppn.PARENTID  = int.Parse(activity);
                    ppn.PART_CERT = partcert;
                    decimal temaa = decimal.Parse(partunitdestiny);
                    //temaa = decimal.Round(decimal.Parse("0.3333333"), 2);
                    ppn.PART_UNITDENSITY = decimal.Round(temaa, 2);
                    ppn.PART_LEVEL       = partlevel;
                    ppn.PART_SPEC        = partspec;
                    ppn.PART_SPEC1       = spec1;
                    ppn.PART_SPEC2       = spec2;
                    ppn.PART_SPEC3       = spec3;
                    ppn.PART_SPEC4       = spec4;
                    ppn.PART_DENSITYUNIT = destinyunit;
                    ppn.PART_UNIT        = partunit;
                    ppn.PART_MAT         = partmat;
                    ppn.PART_TYPE        = parttype;
                    ppn.UPDATEDATE       = DateTime.Today;
                    ppn.UPDATER          = LoginUser;
                    ppn.REPLACE_CODE     = replacecode;
                    if (partpurchase != string.Empty)
                    {
                        ppn.SUPPLYCIRCLE = int.Parse(partpurchase);
                    }
                    else
                    {
                        ppn.SUPPLYCIRCLE = 10;
                    }
                    ppn.ID = int.Parse(dgv1.Rows[i].Cells["序号"].Value.ToString());
                    #region 判断Unit是否是合格格式
                    if (dgv1.Rows[i].Cells["单位"].Value != null && dgv1.Rows[i].Cells["单位"].Value.ToString() != string.Empty)
                    {
                        string    punit = dgv1.Rows[i].Cells["单位"].Value.ToString().Trim().ToLower();
                        DataRow[] pone  = unitds.Tables[0].Select("name ='" + punit + "'");
                        if (pone.Length != 0)
                        {
                            ppn.PART_UNIT = punit;
                        }
                        else
                        {
                            MessageBox.Show("第" + (i + 1) + "行单位名称不规范,请检查!", "错误提示");
                            dgv1.Rows[i].Selected = true;
                            return;
                        }
                    }
                    #endregion
                    int count = ppn.Update();
                    if (count == 0)
                    {
                        MessageBox.Show("第" + partid.ToString() + "行更新失败");
                    }
                }
                #endregion

                MessageBox.Show("保存成功!! ", "温馨提示!");
            }
            catch (Exception err)
            {
                MessageBox.Show("错误原因:" + err.Message, "错误提示信息",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            QuerydataBind();
        }
Beispiel #10
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
        }
Beispiel #11
0
        public void listviewBind(string sql)
        {
            //更改并设置列名称以及属性

            ds = PartParameter.QueryPartPara(sql);
            dgv1.DataSource = ds.Tables[0].DefaultView;
            DataGridViewComboBoxColumn dgvcom = new DataGridViewComboBoxColumn();
            DataSet blockds = PartParameter.QueryPartPara("select block_id,description from project_block_tab where project_id=" + ecprojectid.ToString() + " order by description");
            DataRow rowdim  = blockds.Tables[0].NewRow();

            rowdim[0] = 1;
            blockds.Tables[0].Rows.InsertAt(rowdim, 0);
            dgvcom.DataSource    = blockds.Tables[0].DefaultView;
            dgvcom.DisplayMember = "description";
            dgvcom.ValueMember   = "description";
            dgvcom.HeaderText    = "分段";
            dgvcom.Name          = "分段";
            dgvcom.ReadOnly      = false;
            CalendarColumn dgvcal = new CalendarColumn();

            dgvcal.HeaderText = "预估日期";
            dgvcal.Name       = "预估日期";

            //DateColumn dgvcaln = new DateColumn();
            //dgvcaln.HeaderText = "日期新";
            if (!dgv1.Columns.Contains("预估日期"))
            {
                //dgv1.Columns.Add(dgvcom);
                //dgv1.Columns.Add(dgvcal);
                //dgv1.Columns.Add(dgvcaln);
                //dgv1.Columns["预估日期"].Width = 200;
            }
            dgv1.Columns["预估量"].Width = 100;
            //dgv1.Columns["分段"].Width = 100;
            dgv1.Columns["预估量"].ValueType    = typeof(double);
            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["密度单位"].ReadOnly    = true;
            dgv1.Columns["等级"].ReadOnly      = true;
            dgv1.Columns["单位密度"].ReadOnly    = true;
            dgv1.Columns["parentid"].Visible = false;
            #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(systemid,mmtypeid, 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;
            //            //DataGridViewComboBoxCell combo = new DataGridViewComboBoxCell();

            //            dgv1.Rows[i].Cells["预警系数"].Value = pone.PREDICTION_ALERT;
            //            if (pone.BLOCKID != "0")
            //            {
            //                dgv1.Rows[i].Cells["日期"].Value = pone.CREATEDATE;
            //                dgv1.Rows[i].Cells["分段"].Value = pone.BLOCKID;
            //                //DataGridViewComboBoxCell combo = dgv1.Rows[i].Cells["分段"] as DataGridViewComboBoxCell;
            //                //combo.DataSource = blockds.Tables[0];
            //                //combo.DisplayMember = "description";
            //                //combo.ValueMember = "block_id";
            //                //combo.Value = pone.BLOCKID;
            //            }
            //        }
            //        else
            //        {
            //            dgv1.Rows[i].Cells["预估量"].Value = 0;
            //            dgv1.Rows[i].Cells["预警系数"].Value = 0;
            //        }

            //    }
            //    //}
            //}
            #endregion
        }
        /// <summary>
        /// 根据货物所占百分比画饼图
        /// </summary>
        /// <param name="objgraphics">Graphics类对象</param>
        /// <param name="M_str_sqlstr">SQL语句</param>
        /// <param name="M_str_table">表名</param>
        /// <param name="M_str_Num">数据表中货物数</param>
        /// <param name="M_str_tbGName">数据表中货物名称</param>
        /// <param name="M_str_title">饼图标题</param>
        public void drawPic(Graphics objgraphics, string M_str_sqlstr, string M_str_table, string M_str_Num, string M_str_tbGName, string M_str_title)
        {
            DataSet myds = PartParameter.QueryPartPara(M_str_sqlstr);
            float   M_flt_total = 0.0f, M_flt_tmp;
            int     M_int_iloop;

            for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
            {
                M_flt_tmp    = Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]);
                M_flt_total += M_flt_tmp;
            }
            Font      fontlegend = new Font("verdana", 9), fonttitle = new Font("verdana", 10, FontStyle.Bold); //设置字体
            int       M_int_width        = 275;                                                                 //白色背景宽
            const int Mc_int_bufferspace = 15;
            int       M_int_legendheight = fontlegend.Height * (myds.Tables[0].Rows.Count + 1) + Mc_int_bufferspace;
            int       M_int_titleheight  = fonttitle.Height + Mc_int_bufferspace;
            int       M_int_height       = M_int_width + M_int_legendheight + M_int_titleheight + Mc_int_bufferspace;//白色背景高
            int       M_int_pieheight    = M_int_width;
            Rectangle pierect            = new Rectangle(0, M_int_titleheight, M_int_width, M_int_pieheight);
            //加上各种随机色
            Bitmap objbitmap = new Bitmap(M_int_width, M_int_height);//创建一个bitmap实例

            objgraphics = Graphics.FromImage(objbitmap);
            ArrayList colors = new ArrayList();
            Random    rnd    = new Random();

            for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
            {
                colors.Add(new SolidBrush(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))));
            }
            objgraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, M_int_width, M_int_height); //画一个白色背景
            objgraphics.FillRectangle(new SolidBrush(Color.LightYellow), pierect);                   //画一个亮黄色背景
            //以下为画饼图(有几行row画几个)
            float M_flt_currentdegree = 0.0f;

            for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
            {
                objgraphics.FillPie((SolidBrush)colors[M_int_iloop], pierect, M_flt_currentdegree,
                                    Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) / M_flt_total * 360);
                M_flt_currentdegree += Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) / M_flt_total * 360;
            }
            //以下为生成主标题
            SolidBrush   blackbrush   = new SolidBrush(Color.Black);
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            objgraphics.DrawString(M_str_title, fonttitle, blackbrush, new Rectangle(0, 0, M_int_width, M_int_titleheight), stringFormat);
            objgraphics.DrawRectangle(new Pen(Color.Black, 2), 0, M_int_height - M_int_legendheight, M_int_width, M_int_legendheight);
            for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
            {
                objgraphics.FillRectangle((SolidBrush)colors[M_int_iloop], 5, M_int_height - M_int_legendheight + fontlegend.Height * M_int_iloop + 5, 10, 10);
                objgraphics.DrawString(((String)myds.Tables[0].Rows[M_int_iloop][M_str_tbGName]) + " —— "
                                       + Convert.ToString(Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) * 100 / M_flt_total) + "%", fontlegend, blackbrush,
                                       20, M_int_height - M_int_legendheight + fontlegend.Height * M_int_iloop + 1);
            }
            objgraphics.DrawString("总货物数是:" + Convert.ToString(M_flt_total), fontlegend, blackbrush, 5, M_int_height - fontlegend.Height);
            string P_str_imagePath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,
                                                                                                            Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));

            P_str_imagePath += @"\Image\image\" + DateTime.Now.ToString("yyyyMMddhhmss") + ".jpg";
            objbitmap.Save(P_str_imagePath, ImageFormat.Jpeg);
            objgraphics.Dispose();
            objbitmap.Dispose();
        }