コード例 #1
0
 private void txtWarehouseCode_Leave(object sender, EventArgs e)
 {
     //判断编号是否已存在
     if (!string.IsNullOrEmpty(this.txtWarehouseCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtProductCode.Text.Trim()))
     {
         BaseSafetyStockTable SafetyCode = new BaseSafetyStockTable();
         SafetyCode = bSafetyStock.GetModel(txtWarehouseCode.Text, txtProductCode.Text);
         if (SafetyCode != null)
         {
             txtWarehouseCode.Text = "";
             txtWarehouseName.Text = "";
             txtProductCode.Text   = "";
             txtProductName.Text   = "";
             txtWarehouseCode.Focus();
             MessageBox.Show("仓库编号与商品编号的组合已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     if (!string.IsNullOrEmpty(this.txtWarehouseCode.Text.Trim()))
     {
         BaseWarehouseTable Warehouse  = new BaseWarehouseTable();
         BWarehouse         bWarehouse = new BWarehouse();
         Warehouse = bWarehouse.GetModel(this.txtWarehouseCode.Text);
         if (Warehouse == null || "".Equals(Warehouse))
         {
             txtWarehouseCode.Focus();
             txtWarehouseCode.Text = "";
             txtWarehouseName.Text = "";
             MessageBox.Show("仓库编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtWarehouseName.Text = Warehouse.NAME;
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 删除
 /// </summary>
 private void MasterToolBar_DoDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK)
     {
         try
         {
             GetCurrentSelectedTable();
             if (_currentSafetyStockTable != null)
             {
                 bSafetyStock.Delete(_currentSafetyStockTable.WAREHOUSE_CODE, _currentSafetyStockTable.PRODUCT_CODE);
                 Search(this.pgControl.GetCurrentPage());
             }
             else
             {
                 MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Logger.Error("安全库存删除失败,请重试或与系统管理员联系。", ex);
         }
         _currentSafetyStockTable = null;
     }
 }
コード例 #3
0
ファイル: FrmSafetyStockDialog.cs プロジェクト: zhr008/ERP-1
 private void txtProductCode_Leave(object sender, EventArgs e)
 {
     //判断编号是否已存在
     if (!string.IsNullOrEmpty(this.txtWarehouseCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtProductCode.Text.Trim()))
     {
         BaseSafetyStockTable SafetyCode = new BaseSafetyStockTable();
         SafetyCode = bSafetyStock.GetModel(txtWarehouseCode.Text, txtProductCode.Text);
         if (SafetyCode != null)
         {
             txtWarehouseCode.Text = "";
             txtWarehouseName.Text = "";
             txtProductCode.Text   = "";
             txtProductName.Text   = "";
             txtWarehouseCode.Focus();
             MessageBox.Show("仓库编号与商品编号的组合已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     if (!string.IsNullOrEmpty(this.txtProductCode.Text.Trim()))
     {
         BaseProductTable product  = new BaseProductTable();
         BProduct         bProduct = new BProduct();
         product = bProduct.GetModel(this.txtProductCode.Text);
         if (product == null || "".Equals(product))
         {
             txtProductCode.Focus();
             txtProductCode.Text = "";
             txtProductName.Text = "";
             MessageBox.Show("商品编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtProductCode.Text = product.CODE;
             txtProductName.Text = product.NAME;
             txtUnitCode.Text    = product.BASIC_UNIT_CODE;
             txtUnitName.Text    = product.BASIC_UNIT_NAME;
         }
     }
     else
     {
         txtProductName.Text = "";
     }
 }
コード例 #4
0
ファイル: FrmSafetyStock.cs プロジェクト: zhr008/ERP-1
        /// <summary>
        /// 获得当前选中的数据
        /// </summary>
        private void GetCurrentSelectedTable()
        {
            try
            {
                string warehousecode = dgvData.SelectedRows[0].Cells["WAREHOUSE_CODE"].Value.ToString();
                string productcode   = dgvData.SelectedRows[0].Cells["PRODUCT_CODE"].Value.ToString();
                if (warehousecode != "" && productcode != "")
                {
                    _currentSafetyStockTable = bSafetyStock.GetModel(warehousecode, productcode);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("获取对象失败!");
            }

            if (_currentSafetyStockTable == null || _currentSafetyStockTable.WAREHOUSE_CODE == null || "".Equals(_currentSafetyStockTable.WAREHOUSE_CODE))
            {
                _currentSafetyStockTable = null;
            }
        }
コード例 #5
0
ファイル: FrmSafetyStock.cs プロジェクト: zhr008/ERP-1
 /// <summary>
 /// 打开新窗口
 /// </summary>
 private void OpenDialogFrm(int mode)
 {
     if (mode == CConstant.MODE_NEW || _currentSafetyStockTable != null)
     {
         FrmSafetyStockDialog frm = new FrmSafetyStockDialog();
         frm.UserInfo = _userInfo;
         frm.CurrentSafetyStockTable = _currentSafetyStockTable;
         frm.Mode = mode;
         DialogResult resule = frm.ShowDialog(this);
         if (resule == DialogResult.OK && isSearch)
         {
             Search(this.pgControl.GetCurrentPage());
         }
         frm.Dispose();
     }
     else
     {
         //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     _currentSafetyStockTable = null;
 }
コード例 #6
0
ファイル: FrmSafetyStockDialog.cs プロジェクト: zhr008/ERP-1
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentSafetyStockTable == null)
                {
                    _currentSafetyStockTable = new BaseSafetyStockTable();
                }

                _currentSafetyStockTable.WAREHOUSE_CODE        = txtWarehouseCode.Text;
                _currentSafetyStockTable.PRODUCT_CODE          = txtProductCode.Text;
                _currentSafetyStockTable.UNIT_CODE             = txtUnitCode.Text;
                _currentSafetyStockTable.SAFETY_STOCK          = Convert.ToDecimal(txtSafetyStock.Text);
                _currentSafetyStockTable.MAX_QUANTITY          = Convert.ToDecimal(txtMaxQuantity.Text);
                _currentSafetyStockTable.MIN_PURCHASE_QUANTITY = Convert.ToDecimal(txtMinPurcahseQuantity.Text);
                _currentSafetyStockTable.LAST_UPDATE_USER      = _userInfo.CODE;

                try
                {
                    if (bSafetyStock.Exists(txtWarehouseCode.Text.Trim(), txtProductCode.Text.Trim()))
                    {
                        bSafetyStock.Update(_currentSafetyStockTable);
                    }
                    else
                    {
                        _currentSafetyStockTable.CREATE_USER = _userInfo.CODE;
                        bSafetyStock.Add(_currentSafetyStockTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
コード例 #7
0
ファイル: BSafetyStock.cs プロジェクト: zhr008/ERP-1
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BaseSafetyStockTable model)
 {
     return(dal.Update(model));
 }
コード例 #8
0
ファイル: BSafetyStock.cs プロジェクト: zhr008/ERP-1
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BaseSafetyStockTable model)
 {
     return(dal.Add(model));
 }
コード例 #9
0
        public override string[] doUpdateDB()
        {
            BaseSafetyStockTable StockTable   = null;
            BSafetyStock         bSafetyStock = new BSafetyStock();
            StringBuilder        strError     = new StringBuilder();
            int    successData    = 0;
            int    failureData    = 0;
            string errorFilePath  = "";
            string backupFilePath = "";

            //数据导入处理
            foreach (DataRow dr in _csvDataTable.Rows)
            {
                StringBuilder str = new StringBuilder();
                //仓库编号
                str.Append(CheckWarehouse(CConvert.ToString(GetValue(dr, "WAREHOUSE_CODE")), "仓库编号"));
                //商品编号
                if (CConvert.ToString(GetValue(dr, "PRODUCT_CODE")).Length > 40)
                {
                    string product = GetValue(dr, "PRODUCT_CODE").ToString().Substring(0, 40);
                    str.Append(CheckProduct(product, "商品编号"));
                }
                else
                {
                    str.Append(CheckProduct(CConvert.ToString(GetValue(dr, "PRODUCT_CODE")), "商品编号"));
                }
                //单位
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "UNIT_CODE"))))
                {
                    str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "UNIT_CODE")), "单位"));
                }
                //安全在库数
                str.Append(CheckDecimal(GetValue(dr, "SAFETY_STOCK", 0), 12, 2, "安全在库数"));
                //最大在库数
                str.Append(CheckDecimal(GetValue(dr, "MAX_QUANTITY", 0), 12, 2, "最大在库数"));
                //最小采购数
                str.Append(CheckDecimal(GetValue(dr, "MIN_PURCHASE_QUANTITY", 0), 12, 2, "最小采购数"));
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态"));

                //str.Append(CheckUnit(dr[6], "单位")); //单位

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    int ret = 0;
                    StockTable = new BaseSafetyStockTable();
                    StockTable.WAREHOUSE_CODE = CConvert.ToString(GetValue(dr, "WAREHOUSE_CODE"));
                    if (GetValue(dr, "PRODUCT_CODE").ToString().Length > 20)
                    {
                        StockTable.PRODUCT_CODE = CConvert.ToString(GetValue(dr, "PRODUCT_CODE")).Substring(0, 20);
                    }
                    else
                    {
                        StockTable.PRODUCT_CODE = CConvert.ToString(GetValue(dr, "PRODUCT_CODE"));
                    }
                    StockTable.UNIT_CODE             = CConvert.ToString(GetValue(dr, "UNIT_CODE", "01"));
                    StockTable.SAFETY_STOCK          = CConvert.ToDecimal(GetValue(dr, "SAFETY_STOCK", 0));
                    StockTable.MAX_QUANTITY          = CConvert.ToDecimal(GetValue(dr, "MAX_QUANTITY", 0));
                    StockTable.MIN_PURCHASE_QUANTITY = CConvert.ToDecimal(GetValue(dr, "MIN_PURCHASE_QUANTITY", 0));
                    StockTable.STATUS_FLAG           = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));
                    StockTable.CREATE_USER           = _userInfo.CODE;
                    StockTable.LAST_UPDATE_USER      = _userInfo.CODE;

                    if (!bSafetyStock.Exists(StockTable.WAREHOUSE_CODE, StockTable.PRODUCT_CODE))
                    {
                        bSafetyStock.Add(StockTable);
                    }
                    else
                    {
                        bSafetyStock.Update(StockTable);
                    }
                    successData++;
                }
                catch
                {
                    strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString());
                    failureData++;
                }
            }
            //错误记录处理
            if (strError.Length > 0)
            {
                errorFilePath = WriteFile(strError.ToString());
            }

            //备份处理
            backupFilePath = BackupFile();

            return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath });
        }