Пример #1
0
        private void gvList_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.ColumnEditName == "gridPartNum")
            {
                string partItemNum = (e.RowHandle + 1).ToString();
                string partNum     = e.Value.ToString();
                ByProductPartEntity byProductPartEntity = new ByProductPartEntity();
                DataTable           dtParM = byProductPartEntity.CheckPart(partNum).Tables[0];
                //if (Convert.ToInt32(partItemNum) < 4)
                //{
                GetRules();
                DataTable dtPro = new DataTable();
                dtPro = GetRules();
                for (int j = 0; j < dtPro.Rows.Count; j++)
                {
                    DataRow drPro = dtPro.Rows[j];
                    if (drPro["ITEMNO"].ToString().Trim() == partItemNum && drPro["MODULE"].ToString().Trim() == dtParM.Rows[0]["PART_MODULE"].ToString().Trim())
                    {
                        if (string.IsNullOrEmpty(dtPro.Rows[j]["MINPOWER"].ToString().Trim()))
                        {
                            gvList.SetRowCellValue(e.RowHandle, "MIN_POWER", null);
                        }
                        else
                        {
                            gvList.SetRowCellValue(e.RowHandle, "MIN_POWER", dtPro.Rows[j]["MINPOWER"].ToString().Trim());
                        }

                        if (string.IsNullOrEmpty(dtPro.Rows[j]["MAXPOWER"].ToString().Trim()))
                        {
                            gvList.SetRowCellValue(e.RowHandle, "MAX_POWER", null);
                        }
                        else
                        {
                            gvList.SetRowCellValue(e.RowHandle, "MAX_POWER", dtPro.Rows[j]["MAXPOWER"].ToString().Trim());
                        }
                        gvList.SetRowCellValue(e.RowHandle, "PART_DESC", dtParM.Rows[0]["PART_DESC"].ToString().Trim());
                        break;
                    }
                    else
                    {
                        gvList.SetRowCellValue(e.RowHandle, "PART_DESC", dtParM.Rows[0]["PART_DESC"].ToString().Trim());
                        gvList.SetRowCellValue(e.RowHandle, "MIN_POWER", null);
                        gvList.SetRowCellValue(e.RowHandle, "MAX_POWER", null);
                    }
                }
            }
        }
Пример #2
0
        private void txtPartId_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                try
                {
                    string  partId      = string.Empty;
                    DataSet dsCheckPart = new DataSet();
                    //chack料号是否存在且可用
                    ByProductPartEntity byProductPartEntity = new ByProductPartEntity();
                    partId      = txtPartId.Text.Trim();
                    dsCheckPart = byProductPartEntity.CheckPart(partId);
                    if (dsCheckPart.Tables[0].Rows.Count > 0)
                    {
                        DataSet   dsGetByPartId  = byProductPartEntity.GetByPartId(partId);
                        DataTable dtGetByPartId  = new DataTable();
                        DataTable dsGetByPartId2 = new DataTable();
                        dtGetByPartId  = dsGetByPartId.Tables["POR_PART_BYPRODUCT"];
                        dsGetByPartId2 = dsGetByPartId.Tables["POR_PART"];
                        //if (!dtGetByPartId.Columns.Contains("ROWNUMBER"))
                        //    dtGetByPartId.Columns.Add("ROWNUMBER");
                        if (dtGetByPartId.Rows.Count > 0)
                        {
                            //for (int i = 0; i < dtGetByPartId.Rows.Count; i++)
                            //{
                            //    dtGetByPartId.Rows[i]["ROWNUMBER"] = i + 1;
                            //}
                            //如果存在且已经有对应料号则带出所有的对应料号信息

                            //遍历查询结果
                            for (int i = 0; i < dtGetByPartId.Rows.Count; i++)
                            {
                                string   gradesOut     = string.Empty;
                                string   gradesOutUsed = string.Empty;
                                string   grades        = dtGetByPartId.Rows[i]["GRADES"].ToString().Trim(); ///获取等级列信息
                                string[] arrTemp       = grades.Split(',');                                 ///数组取值(等级组所有等级)
                                for (int j = 0; j < arrTemp.Length; j++)
                                {
                                    gradesOut += GetProductGradeDisplayText(arrTemp[j]) + ",";   ///调用等级转换将转换数据重新组合,并用逗号隔开
                                }
                                gradesOutUsed = gradesOut.Remove(gradesOut.LastIndexOf(","), 1); ///去掉最后的,号
                                dtGetByPartId.Rows[i]["GRADES"] = gradesOutUsed;
                            }///列重新赋值

                            gcList.DataSource = dtGetByPartId;
                            txtDesc.Text      = dsGetByPartId2.Rows[0]["PART_DESC"].ToString().Trim();
                            OnAfterStateChanged(ControlState.Edit);
                        }
                        else
                        {
                            //如果存在但未进行绑定联副产品则带出首条对应料号即为主料号
                            DataRow dr = dtGetByPartId.NewRow();
                            dr["ITEM_NO"]     = "1";
                            dr["PART_NUMBER"] = partId;

                            DataTable dtPro = new DataTable();
                            dtPro = GetRules();
                            for (int j = 0; j < dtPro.Rows.Count; j++)
                            {
                                DataRow drPro = dtPro.Rows[j];
                                if (drPro["ITEMNO"].ToString().Trim() == "1" && drPro["MODULE"].ToString().Trim() == dsGetByPartId2.Rows[0]["PART_MODULE"].ToString().Trim())
                                {
                                    string   gradesOut     = string.Empty;
                                    string   gradesOutUsed = string.Empty;
                                    string   grades        = dtPro.Rows[j]["GRADES"].ToString().Trim(); ///获取等级列信息
                                    string[] arrTemp       = grades.Split(',');                         ///数组取值(等级组所有等级)
                                    for (int i = 0; i < arrTemp.Length; i++)
                                    {
                                        gradesOut += GetProductGradeDisplayText(arrTemp[i]) + ",";   ///调用等级转换将转换数据重新组合,并用逗号隔开
                                    }
                                    gradesOutUsed = gradesOut.Remove(gradesOut.LastIndexOf(","), 1); ///去掉最后的,号

                                    dr["GRADES"] = gradesOutUsed;                                    ///列重新赋值
                                                                                                     ///if (string.IsNullOrEmpty(dtPro.Rows[j]["MINPOWER"].ToString().Trim()))
                                    if (!string.IsNullOrEmpty(dtPro.Rows[j]["MINPOWER"].ToString().Trim()))
                                    {
                                        dr["MIN_POWER"] = dtPro.Rows[j]["MINPOWER"].ToString().Trim();
                                    }

                                    if (!string.IsNullOrEmpty(dtPro.Rows[j]["MAXPOWER"].ToString().Trim()))
                                    {
                                        dr["MAX_POWER"] = dtPro.Rows[j]["MAXPOWER"].ToString().Trim();
                                    }

                                    dr["STORAGE_LOCATION"] = dtPro.Rows[j]["STORAGE"].ToString().Trim();
                                }
                            }
                            dr["PART_DESC"] = dsGetByPartId2.Rows[0]["PART_DESC"].ToString().Trim();

                            dtGetByPartId.Rows.Add(dr);
                            gcList.DataSource = dtGetByPartId;
                            txtDesc.Text      = dsGetByPartId2.Rows[0]["PART_DESC"].ToString().Trim();
                            OnAfterStateChanged(ControlState.Edit);
                        }
                    }
                    else
                    {
                        //如果不存在料号则提示料号不存在,请先进行料号维护
                        //MessageBox.Show("料号不存在,请先进行料号维护,然后执行此操作!", "系统错误提示");
                        MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.ByProductPartForm.msg.0001}"), StringParser.Parse("${res:Global.SystemInfo}"));

                        txtPartId.Focus();
                        txtPartId.SelectAll();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, StringParser.Parse("${res:Global.SystemInfo}"));
                }
            }
        }