Exemple #1
0
        void loadUserControl()
        {
            ArrayList listPara = MaterialParamNSBO.Instance.FindByAttribute("MaterialNSID", MaterialNS.ID);

            foreach (var para in listPara)
            {
                MaterialParamNSModel param = (MaterialParamNSModel)para;
                ucDetailTS           uc    = new ucDetailTS();
                uc.ParamNS = param;
                flpThongSo.Controls.Add(uc);
            }
        }
Exemple #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (flpThongSo.Controls.Count == 0)
                {
                    return;
                }
                _materialCode = MaterialNS.Code;
                _materialName = MaterialNS.Code;

                DataTable dtPart = TextUtils.Select("SELECT top 1 [PartsCode] FROM [ProductionManagement].[dbo].[Parts] where Replace(PartsCode,' ','') = '"
                                                    + MaterialNS.Code + "'");
                if (dtPart.Rows.Count > 0)
                {
                    MessageBox.Show("Mã vật tư đã có trên quản lý sản xuất!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                bool error = false;
                foreach (Control control in flpThongSo.Controls)
                {
                    ucDetailTS uc = (ucDetailTS)control;
                    if (uc.Value == "")
                    {
                        error = true;
                        break;
                    }
                    _materialCode = _materialCode.Replace("[" + uc.ParamNS.Code + "]", uc.Value);
                    _materialName = _materialName.Replace("[" + uc.ParamNS.Code + "]", uc.ParamNS.Name + ":" + uc.Value
                                                          + uc.ParamNS.Unit + (uc.Des == "" ? "" : "(" + uc.Des + ")"));
                }
                if (error)
                {
                    //txtCode.Text = "";
                    txtFull.Text = "";
                    MessageBox.Show("Không thể tạo được vật tư phi tiêu chuẩn.\n Chưa điền đầy đủ giá trị cho các thông số",
                                    TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                int i = _materialName.IndexOf('-');
                txtFull.Text = "Mã vật tư: " + _materialCode + Environment.NewLine + "Tên vật tư: " + _materialName.Replace(_materialName.Substring(0, i), MaterialNS.Name);
                txtCode.Text = _materialCode;
                txtName.Text = _materialName.Replace(_materialName.Substring(0, i), MaterialNS.Name);
                txtFull.SelectAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tạo mã không thành công!\n Có thể mã vật tư phi tiêu chuẩn không đúng định dạng!" + Environment.NewLine + ex.Message);
            }
        }