Ejemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }

            if (_currentUserTable == null)
            {
                _currentUserTable = new BaseUserTable();
            }

            _currentUserTable.CODE            = (txtCompanyCode.Text + txtCode.Text.Trim());
            _currentUserTable.NAME            = txtName.Text;
            _currentUserTable.PASSWORD        = DESEncrypt.Encrypt(txtPassword.Text);
            _currentUserTable.PHONE           = txtPhone.Text;
            _currentUserTable.EMAIL           = txtEmail.Text;
            _currentUserTable.DEPARTMENT_CODE = txtDepartmentCode.Text;
            _currentUserTable.COMPANY_CODE    = txtCompanyCode.Text;
            _currentUserTable.ROLES_CODE      = txtRolesCode.Text;
            //_currentUserTable.PHOTO = GetImageToByte(txtPhoto.Text);
            _currentUserTable.PHOTO            = null;
            _currentUserTable.LAST_UPDATE_USER = _userInfo.CODE;
            if (txtIntCommunityDate.Checked == true)
            {
                _currentUserTable.INT_COMMUNITY_DATE = CConvert.ToDateTime(txtIntCommunityDate.Text);
            }
            else
            {
                _currentUserTable.INT_COMMUNITY_DATE = null;
            }
            if (txtOutCommunityDate.Checked == true)
            {
                _currentUserTable.OUT_COMMUNITY_DATE = CConvert.ToDateTime(txtOutCommunityDate.Text);
            }
            else
            {
                _currentUserTable.OUT_COMMUNITY_DATE = null;
            }
            try
            {
                if (bUser.Exists(_currentUserTable.CODE, _currentUserTable.COMPANY_CODE))
                {
                    bUser.Update(_currentUserTable);
                }
                else
                {
                    _currentUserTable.CREATE_USER = _userInfo.CODE;
                    bUser.Add(_currentUserTable);
                }
            }
            catch (Exception ex)
            {
                //log.error
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            result = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BaseDrawingTable GetModel(string CODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from BASE_DRAWING ");
            strSql.Append(" where CODE=@CODE ");
            strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE);
            SqlParameter[] parameters =
            {
                new SqlParameter("@CODE", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = CODE;

            BaseDrawingTable model = new BaseDrawingTable();
            DataSet          ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.CODE             = ds.Tables[0].Rows[0]["CODE"].ToString();
                model.NAME             = ds.Tables[0].Rows[0]["NAME"].ToString();
                model.STATUS_FLAG      = CConvert.ToInt32(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString());
                model.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString();
                model.LAST_UPDATE_TIME = CConvert.ToDateTime(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString());
                model.MEMO             = ds.Tables[0].Rows[0]["MEMO"].ToString();
                model.CREATE_USER      = ds.Tables[0].Rows[0]["CREATE_USER"].ToString();
                model.CREATE_DATE_TIME = CConvert.ToDateTime(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString());

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        private void initOperate(int currentPage)
        {
            BllShipmentTable    shipment    = bShipment.GetModel(slipnumber);
            BllOrderHeaderTable orderheader = bOrderHeader.GetModel(shipment.ORDER_SLIP_NUMBER);

            txtSlipNumber.Text      = slipnumber;
            txtOrderSlipNumber.Text = shipment.ORDER_SLIP_NUMBER;
            //txtCustomerCode.Text = orderheader.CUSTOMER_CODE;
            //txtCustomerName.Text = orderheader.CUSTOMER_NAME;
            txtEndCustomerCode.Text = orderheader.ENDER_CUSTOMER_CODE;
            txtEndCustomerName.Text = orderheader.ENDER_CUSTOMER_NAME;
            //txtDeliveryPointCode.Text = orderheader.ENDER_CUSTOMER_CODE;
            //txtDeliveryPointName.Text = orderheader.ENDER_CUSTOMER_NAME;
            //txtSerialNumber.Text = shipment.SERIAL_NUMBER;
            txtCustomerPoNumber.Text   = orderheader.CUSTOMER_PO_NUMBER;
            txtOrderSlipDateFrom.Value = CConvert.ToDateTime(orderheader.SLIP_DATE.ToString());
            txtOrderSlipDateTo.Value   = CConvert.ToDateTime(orderheader.SLIP_DATE.ToString());
            txtSlipDateFrom.Value      = CConvert.ToDateTime(shipment.SLIP_DATE.ToString("yyyy-MM-dd"));
            txtSlipDateTo.Value        = CConvert.ToDateTime(shipment.SLIP_DATE.ToString("yyyy-MM-dd"));
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" STATUS_FLAG <> {0}", CConstant.DELETE);
            sb.AppendFormat(" AND SLIP_NUMBER = '{0}'", slipnumber);
            DataSet ds          = bShipment.GetList(sb.ToString(), "", (currentPage - 1) * PageSize + 1, currentPage * PageSize);
            int     recordCount = bShipment.GetRecordCount(sb.ToString());

            _currentDt = ds.Tables[0];
            reSetCurrentDt();
            this.dgvData.DataSource = _currentDt;
            this.pgControl.init(GetTotalPage(recordCount), currentPage);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == dgvData.Columns["BTN_SLIP_NUMBER"].Index)
                {
                    FrmPurchaseOrderSearch frm = new FrmPurchaseOrderSearch();
                    frm.CTag = CConstant.PURCHASE_ORDER_MASTER_SEARCH;

                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (!IsExist(frm.CurrentPurchaseOrderTable.SLIP_NUMBER, null))
                        {
                            if (frm.CurrentPurchaseOrderTable != null)
                            {
                                DataGridViewRow dr         = dgvData.Rows[e.RowIndex];
                                string          slipNumber = frm.CurrentPurchaseOrderTable.SLIP_NUMBER;
                                dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value = slipNumber;
                                dr.Cells["TOTAL_AMOUNT"].Value             = frm.CurrentPurchaseOrderTable.TOTAL_AMOUNT;
                                dr.Cells["PURCHASE_ORDER_SLIP_DATE"].Value = CConvert.ToDateTime(frm.CurrentPurchaseOrderTable.SLIP_DATE).ToString("yyyy-MM-dd");
                                dr.Cells["ARR_AMOUNT"].Value = bDepositArr.GetArrAmount(slipNumber);
                            }
                        }
                    }
                    frm.Dispose();
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 5
0
        private void btnAddProductionProcess_Click(object sender, EventArgs e)
        {
            FrmMasterSearch frm = new FrmMasterSearch("PRODUCTION_PROCESS", "");

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                string  strWhere        = " CODE = " + "'" + frm.BaseMasterTable.Code + "'";
                DataSet ds              = BProductionProcess.GetList(strWhere);
                string  departmentcode  = ds.Tables[0].Rows[0]["DEPARTMENT_CODE"].ToString().Trim();
                string  departmentname  = ds.Tables[0].Rows[0]["DEPARTMENT_NAME"].ToString().Trim();
                decimal productioncycle = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRODUCTION_CYCLE"].ToString().Trim());
                if (dgvData.Rows.Count > 0)
                {
                    int      dgvrow    = dgvData.Rows.Count - 1;
                    DateTime StartDate = CConvert.ToDateTime(dgvData.Rows[dgvrow].Cells["END_DATE"].Value.ToString());
                    DateTime EndDate   = StartDate.AddDays(CConvert.ToDouble(productioncycle) + 0D);
                    object[] rows      = { "", frm.BaseMasterTable.Code, frm.BaseMasterTable.Name, departmentcode, departmentname, StartDate, EndDate, "", productioncycle };
                    dgvData.Rows.Add(rows);
                }
                else
                {
                    DateTime EndDate = CConvert.ToDateTime(txtSlipDateFrom.Text).AddDays(CConvert.ToDouble(productioncycle) + 0D);
                    object[] rows    = { "", frm.BaseMasterTable.Code, frm.BaseMasterTable.Name, departmentcode, departmentname, txtSlipDateFrom.Text, EndDate, "", productioncycle };
                    dgvData.Rows.Add(rows);
                }
            }
            frm.Dispose();
        }
Ejemplo n.º 6
0
        private void FrmMasterMachineDialog_Load(object sender, EventArgs e)
        {
            #region 维修地点初始化
            try
            {
                cboMaintenanceStations.ValueMember   = "CODE";
                cboMaintenanceStations.DisplayMember = "NAME";
                cboMaintenanceStations.DataSource    = CCacheData.Stations;
            }
            catch { }
            #endregion

            if (_currentMasterMachineTable != null)
            {
                txtMachineCode.Text  = _currentMasterMachineTable.MACHINE_CODE;
                txtMachineName.Text  = _currentMasterMachineTable.MACHINE_NAME;
                txtCustomerCode.Text = _currentMasterMachineTable.CUSTOMER_CODE;
                if (!string.IsNullOrEmpty(_currentMasterMachineTable.CUSTOMER_CODE))
                {
                    txtCustomerName.Text = bCommon.GetBaseMaster("CUSTOMER", _currentMasterMachineTable.CUSTOMER_CODE).Name;
                }
                txtProductCode.Text = _currentMasterMachineTable.PRODUCT_CODE;
                if (!string.IsNullOrEmpty(_currentMasterMachineTable.PRODUCT_CODE))
                {
                    txtProductName.Text = bCommon.GetBaseMaster("PRODUCT", _currentMasterMachineTable.PRODUCT_CODE).Name;
                }
                txtPurchaseOrderSlipNumber.Text      = _currentMasterMachineTable.PURCHASE_ORDER_SLIP_NUMBER;
                txtFSerialNumber.Text                = _currentMasterMachineTable.FANUC_SERIAL_NUMBER;
                txtFSlipNUmber.Text                  = _currentMasterMachineTable.FANUC_SLIP_NUMBER;
                txtReceiptDate.Value                 = _currentMasterMachineTable.RECEIPT_DATE;
                cboMaintenanceStations.SelectedValue = _currentMasterMachineTable.MAINTENANCE_STATIONS;
                txtPurchaseSlipNumber.Text           = _currentMasterMachineTable.PURCHASE_SLIP_NUMBER;
                if (_currentMasterMachineTable.SALE_DATE_TIME != null)
                {
                    txtSaleTime.Checked = true;
                    txtSaleTime.Value   = CConvert.ToDateTime(_currentMasterMachineTable.SALE_DATE_TIME);
                }
                else
                {
                    txtSaleTime.Checked = false;
                }
            }
            if (_mode == CConstant.MODE_NEW)
            {
                this.Text = "新建";
            }
            else if (_mode == CConstant.MODE_MODIFY)
            {
                this.Text = "编辑";
                txtMachineCode.BackColor = Color.WhiteSmoke;
                txtMachineCode.Enabled   = false;
            }
            else if (_mode == CConstant.MODE_COPY)
            {
                this.Text           = "新建";
                txtMachineCode.Text = "";
            }
        }
Ejemplo n.º 7
0
        private void init()
        {
            BaseProductTable product = null;
            DataSet          ds      = bPurchaseOrder.GetList(strWhere);

            int     i   = 1;
            DataRow row = null;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                row                = dt.NewRow();
                row["NO"]          = i++;
                row["SLIP_NUMBER"] = dr["SLIP_NUMBER"];
                string code = CConvert.ToString(dr["PRODUCT_CODE"]);
                product             = new BProduct().GetModel(code);
                row["PRODUCT_CODE"] = dr["PRODUCT_CODE"];
                row["PRODUCT_NAME"] = dr["PRODUCT_NAME"];
                if (product == null)
                {
                    product = new BaseProductTable();
                }
                row["SPEC"]          = product.SPEC;
                row["SUPPLIER_NAME"] = dr["SUPPLIER_NAME"];
                row["QUANTITY"]      = (int)CConvert.ToDecimal(dr["QUANTITY"]);
                row["PRICE"]         = dr["PRICE"];
                row["AMOUNT"]        = dr["AMOUNT_INCLUDED_TAX"];
                row["SLIP_DATE"]     = CConvert.ToDateTime(dr["SLIP_DATE"]).ToString("yyyy-MM-dd");
                row["DUE_DATE"]      = CConvert.ToDateTime(dr["DUE_DATE"]).ToString("yyyy-MM-dd");
                DateTime now = CConvert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                DateTime due = CConvert.ToDateTime(CConvert.ToDateTime(dr["DUE_DATE"]).ToString("yyyy-MM-dd"));
                if (now > due)
                {
                    TimeSpan ts = now - due;
                    row["DUE_STATUS"] = "超过期限" + ts.TotalDays + "天";
                }
                else
                {
                    row["DUE_STATUS"] = "未到时间";
                }
                getReceipt(CConvert.ToString(dr["SLIP_NUMBER"]));
                if (Receipt == CConstant.UN_RECEIPT)
                {
                    row["DELIVERY_STATUS"] = "未入库";
                }
                else if (Receipt == CConstant.COMPLETE_RECEIPT)
                {
                    row["DELIVERY_STATUS"] = "入库完了";
                }
                else if (Receipt == CConstant.PART_RECEIPT)
                {
                    row["DELIVERY_STATUS"] = "入库一部分";
                }
                row["ACTUAL_AMOUNT"] = bPurchaseOrder.GetReceiptActualQuantity(CConvert.ToString(dr["SLIP_NUMBER"]), CConvert.ToString(dr["PRODUCT_CODE"]));
                total += CConvert.ToDecimal(dr["AMOUNT_INCLUDED_TAX"]);
                dt.Rows.Add(row);
            }
        }
Ejemplo n.º 8
0
 private void Init()
 {
     _currentTable = bOrderHeader.GetOrderServiceMode(_slipNumber);
     if (_currentTable != null)
     {
         txtTitle.Text       = _currentTable.TITLE;
         txtStartTime.Value  = CConvert.ToDateTime(_currentTable.START_DATE_TIME);
         txtEndTime.Value    = CConvert.ToDateTime(_currentTable.END_DATE_TIME);
         txtServiceUser.Text = _currentTable.SERVICE_USER;
         txtMemo.Text        = _currentTable.MEMO;
     }
 }
Ejemplo n.º 9
0
        private void initDta()
        {
            BllReReceiptTable RRTable = bReceipt.GetReModel(_slip_number);

            if (RRTable != null)
            {
                try
                {
                    SlipDate.Value       = CConvert.ToDateTime(RRTable.SLIP_DATE);
                    txtSupplierCode.Text = RRTable.SUPPLIER_CODE;
                    if (bCommon.GetBaseMaster("SUPPLIER", RRTable.SUPPLIER_CODE) != null)
                    {
                        txtSupplierName.Text = bCommon.GetBaseMaster("SUPPLIER", RRTable.SUPPLIER_CODE).Name;
                    }
                    txtPurchaseNumber.Text = RRTable.PO_SLIP_NUMBER;
                    foreach (DataRow dr in CCacheData.Taxation.Rows)
                    {
                        if (CConvert.ToDecimal(dr["TAX_RATE"]) == CConvert.ToDecimal(RRTable.TAX_RATE) * 100)
                        {
                            this.cboTax.SelectedValue = dr["CODE"];
                            break;
                        }
                    }
                    cboReturn.SelectedValue = RRTable.RERECEIPT_FLAG;
                    foreach (BllReReceiptLineTable RRLTable in RRTable.Items)
                    {
                        int             currentRowIndex = dgvData.Rows.Add(1);
                        DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                        row.Cells[1].Selected           = false;
                        row.Cells["NO"].Value           = RRLTable.LINE_NUMBER;
                        row.Cells["PRODUCT_CODE"].Value = RRLTable.PRODUCT_CODE;
                        BaseProductTable product = bProduct.GetModel(RRLTable.PRODUCT_CODE);
                        if (product != null)
                        {
                            row.Cells["NAME"].Value = product.NAME;
                            row.Cells["SPEC"].Value = product.SPEC + " " + product.MODEL_NUMBER;
                        }
                        row.Cells["QUANTITY"].Value = RRLTable.QUANTITY;
                        if (bCommon.GetBaseMaster("UNIT", RRLTable.UNIT_CODE) != null)
                        {
                            row.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", RRLTable.UNIT_CODE).Name;
                        }
                        row.Cells["PRICE"].Value  = RRLTable.PRICE;
                        row.Cells["AMOUNT"].Value = RRLTable.PRICE * RRLTable.QUANTITY;
                        row.Cells["AMOUNT_INCLUDED_TAX"].Value = RRLTable.PRICE * RRLTable.QUANTITY * (1 + RRTable.TAX_RATE);
                        row.Cells["MEMO"].Value = RRLTable.MEMO;
                    }
                }
                catch (Exception ex)
                { }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewRow dr = dgvData.Rows[e.RowIndex];
                if (e.ColumnIndex == dgvData.Columns["PURCHASE_ORDER_SLIP_NUMBER"].Index)
                {
                    string purchaseOrderSlipNumber = CConvert.ToString(dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value).Trim();
                    string no = CConvert.ToString(dr.Cells["NO"].Value).Trim();
                    if (purchaseOrderSlipNumber != "")
                    {
                        BllPurchaseOrderTable purchaseOrderTable = bPurchaseOrder.GetModel(purchaseOrderSlipNumber);
                        if (purchaseOrderTable != null)
                        {
                            if (!IsExist(purchaseOrderSlipNumber, no))
                            {
                                dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value = purchaseOrderTable.SLIP_NUMBER;
                                dr.Cells["PURCHASE_ORDER_SLIP_DATE"].Value   = CConvert.ToDateTime(purchaseOrderTable.SLIP_DATE).ToString("yyyy-MM-dd");
                                dr.Cells["TOTAL_AMOUNT"].Value = purchaseOrderTable.TOTAL_AMOUNT;
                                dr.Cells["ARR_AMOUNT"].Value   = bDepositArr.GetArrAmount(purchaseOrderTable.SLIP_NUMBER);
                            }
                        }
                        else
                        {
                            MessageBox.Show("订单编号不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value = "";
                            dr.Cells["PURCHASE_ORDER_SLIP_DATE"].Value   = "";
                            dr.Cells["TOTAL_AMOUNT"].Value = "";
                            dr.Cells["ARR_AMOUNT"].Value   = "0";
                            dr.Cells["AMOUNT"].Value       = "";
                        }
                    }
                }
                else if (e.ColumnIndex == dgvData.Columns["AMOUNT"].Index)
                {
                    string amount = CConvert.ToString(dr.Cells["AMOUNT"].Value);

                    if (amount == "")
                    {
                        dr.Cells["AMOUNT"].Value = 0;
                    }
                    else
                    {
                        dr.Cells["AMOUNT"].Value = CConvert.ToDecimal(amount);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("CellValidated error!", ex);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获得查询条件
        /// </summary>
        private string GetConduction()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" STATUS_FLAG <> {0}", CConstant.DELETE);
            if (Exchangedate.Checked)
            {
                sb.AppendFormat(" and EXCHANGE_DATE = '{0}'", CConvert.ToDateTime(Exchangedate.Value.ToString("yyyy-MM")));
            }
            sb.AppendFormat(" and FROM_CURRENCY_CODE = '{0}'", cboCurrency.SelectedValue);

            return(sb.ToString());
        }
Ejemplo n.º 12
0
        private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow dr = dgvData.Rows[e.RowIndex];

            if (e.ColumnIndex == dgvData.Columns["START_DATE"].Index)
            {
                if (dr.Cells["START_DATE"].Value != null)
                {
                    if (!r.IsMatch(dr.Cells["START_DATE"].Value.ToString().Trim()))
                    {
                        MessageBox.Show("请输入正确的日期。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
                    }
                }
            }
            else if (e.ColumnIndex == dgvData.Columns["END_DATE"].Index)
            {
                if (dr.Cells["END_DATE"].Value != null)
                {
                    if (!r.IsMatch(dr.Cells["END_DATE"].Value.ToString().Trim()))
                    {
                        MessageBox.Show("请输入正确的日期。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
                    }
                }
            }

            else if (e.ColumnIndex == dgvData.Columns["PRODUCTION_CYCLE"].Index)
            {
                int j = 0;
                foreach (DataGridViewRow dr1 in dgvData.Rows)
                {
                    string  strWhere = " CODE = " + "'" + dr.Cells["PRODUCTION_PROCESS_CODE"].Value.ToString() + "'";
                    DataSet ds       = BProductionProcess.GetList(strWhere);

                    decimal productioncycle = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRODUCTION_CYCLE"].ToString().Trim());
                    if (j != 0)
                    {
                        dr1.Cells["START_DATE"].Value = CConvert.ToDateTime(dgvData.Rows[j - 1].Cells["END_DATE"].Value.ToString()).AddDays(1);
                        dr1.Cells["END_DATE"].Value   = CConvert.ToDateTime(dgvData.Rows[j].Cells["START_DATE"].Value.ToString()).AddDays(CConvert.ToDouble(dgvData.Rows[j].Cells["PRODUCTION_CYCLE"].Value) + 0D);
                        j++;
                    }
                    else
                    {
                        dr1.Cells["START_DATE"].Value = txtSlipDateFrom.Text;
                        dr1.Cells["END_DATE"].Value   = CConvert.ToDateTime(txtSlipDateFrom.Text).AddDays(CConvert.ToDouble(dgvData.Rows[0].Cells["PRODUCTION_CYCLE"].Value) + 0D);
                        j++;
                    }
                }
            }
        }
Ejemplo n.º 13
0
 private void ReportedDate_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim()) && ExchangeDate.Value != null)
     {
         BaseExchangeTable exchange = new BaseExchangeTable();
         exchange = bExchange.GetModel(CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")), txtCurrencyCode.Text);
         if (exchange != null)
         {
             ExchangeDate.Value   = DateTime.Now;
             txtCurrencyCode.Text = "";
             ExchangeDate.Focus();
             MessageBox.Show("当月此货币汇率已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Ejemplo n.º 14
0
        private void btnDown_Click(object sender, EventArgs e)
        {
            if (dgvData.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请先选择一行记录。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataGridViewRow dgvr  = dgvData.SelectedRows[0];
            int             index = dgvr.Index;

            if (index == dgvData.Rows.Count - 1)
            {
                MessageBox.Show("选中行己经是最后一行了。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataGridViewRow newDgvr = (DataGridViewRow)dgvr.Clone();

            for (int i = 0; i < dgvr.Cells.Count; i++)
            {
                newDgvr.Cells[i].Value = dgvr.Cells[i].Value;
            }
            dgvData.Rows.RemoveAt(index);
            dgvData.Rows.Insert(index + 1, newDgvr);
            dgvData.Rows[index + 1].Selected = true;
            int j = 0;

            foreach (DataGridViewRow dr in dgvData.Rows)
            {
                string  strWhere = " CODE = " + "'" + dr.Cells["PRODUCTION_PROCESS_CODE"].Value.ToString() + "'";
                DataSet ds       = BProductionProcess.GetList(strWhere);

                decimal productioncycle = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRODUCTION_CYCLE"].ToString().Trim());
                if (j != 0)
                {
                    dr.Cells["START_DATE"].Value = CConvert.ToDateTime(dgvData.Rows[j - 1].Cells["END_DATE"].Value.ToString());
                    dr.Cells["END_DATE"].Value   = CConvert.ToDateTime(dgvData.Rows[j].Cells["START_DATE"].Value.ToString()).AddDays(CConvert.ToDouble(productioncycle) + 0D);
                    j++;
                }
                else
                {
                    dr.Cells["START_DATE"].Value = txtSlipDateFrom.Text;
                    dr.Cells["END_DATE"].Value   = CConvert.ToDateTime(txtSlipDateFrom.Text).AddDays(CConvert.ToDouble(productioncycle) + 0D);
                    j++;
                }
            }
        }
Ejemplo n.º 15
0
        //#region   包装费用
        //private void btnDivPackAmount_Click(object sender, EventArgs e)
        //{
        //    if (txtPackAmount.Text != "")
        //    {
        //        if (CConvert.ToDecimal(txtPackAmount.Text) > 0 && hashTable.Count > 0 && total_un_invoice_amount > 0)
        //        {
        //            decimal total = CConvert.ToDecimal(txtPackAmount.Text);
        //            decimal other = 0;
        //            int i = 1;
        //            foreach (DataGridViewRow row in dgvData.Rows)
        //            {
        //                if (i < dgvData.Rows.Count)
        //                {
        //                    if (row.Cells["PO_SLIP_NUMBER"].Value != null && row.Cells["PO_SLIP_NUMBER"].Value.ToString() != "")
        //                    {
        //                        row.Cells["PACKAGE_AMOUNT"].Value = Math.Round((CConvert.ToDecimal(row.Cells["UN_INVOICE_AMOUNT"].Value) / total_un_invoice_amount) * total, 2);
        //                        other += CConvert.ToDecimal(row.Cells["PACKAGE_AMOUNT"].Value);
        //                        i++;
        //                    }
        //                }
        //                else if (i == dgvData.Rows.Count)
        //                {
        //                    if (row.Cells["PO_SLIP_NUMBER"].Value != null && row.Cells["PO_SLIP_NUMBER"].Value.ToString() != "")
        //                    {
        //                        row.Cells["PACKAGE_AMOUNT"].Value = total - other;
        //                    }
        //                }
        //            }
        //        }
        //        else
        //        {
        //            MessageBox.Show("包装费用不能小于0!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        //        }
        //    }
        //    else
        //    {
        //        MessageBox.Show("包装费用不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        //        return;
        //    }
        //}
        //#endregion

        #region dgvData单元格验证
        private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow dr           = dgvData.Rows[e.RowIndex];
            string          suppliercode = CConvert.ToString(dr.Cells["SUPPLIER_CODE"].Value);

            if (!string.IsNullOrEmpty(suppliercode))
            {
                if (e.ColumnIndex == dgvData.Columns["AMOUNT"].Index)
                {
                    if (CConvert.ToDecimal(dr.Cells["AMOUNT"].Value) > CConvert.ToDecimal(dr.Cells["AMOUNT_INCLUDED_TAX"].Value))
                    {
                        MessageBox.Show("开票金额不能大于金额!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dr.Cells["AMOUNT"].Value    = "";
                        dr.Cells["AMOUNT"].Selected = true;
                    }

                    if (new BSupplier().GetModel(suppliercode).TYPE == 1)
                    {
                        string productcode = CConvert.ToString(dr.Cells["PRODUCT_CODE"].Value);
                        if (!string.IsNullOrEmpty(productcode))
                        {
                            string   hscode = new BProduct().GetModel(productcode).HS_CODE;
                            decimal  exch   = 0;
                            DateTime date   = CConvert.ToDateTime(txtPurchaseDate.Value.Year + "/" + txtPurchaseDate.Value.Month + "/" + 1);
                            try
                            {
                                exch = new BExchange().GetModel(date, dr.Cells["CURRENCY_CODE"].Value.ToString()).EXCHANGE_RATE;
                            }
                            catch { exch = 1; }
                            if (!string.IsNullOrEmpty(hscode))
                            {
                                decimal tax = new BHsCode().GetModel(hscode).TAX_RATE;
                                dr.Cells["TAX_AMOUNT"].Value = CConvert.ToDecimal(dr.Cells["AMOUNT"].Value) * (tax / 100) * (exch / 100);
                            }
                            else
                            {
                                dr.Cells["TAX_AMOUNT"].Value = 0;
                            }
                        }
                        else
                        {
                            dr.Cells["TAX_AMOUNT"].Value = 0;
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 获得当前选中的数据
        /// </summary>
        private void GetCurrentSelectedTable()
        {
            try
            {
                DateTime date     = CConvert.ToDateTime(CConvert.ToDateTime(dgvData.SelectedRows[0].Cells["EXCHANGE_DATE"].Value).ToString("yyyy-MM"));
                string   currency = CConvert.ToString(dgvData.SelectedRows[0].Cells["FROM_CURRENCY_CODE"].Value);
                if (date != null && !string.IsNullOrEmpty(currency))
                {
                    _currentExchangeTable = bExchange.GetModel(date, currency);
                }
            }
            catch (Exception ex) { }

            if (_currentExchangeTable == null || _currentExchangeTable.FROM_CURRENCY_CODE == null || "".Equals(_currentExchangeTable.FROM_CURRENCY_CODE))
            {
                _currentExchangeTable = null;
            }
        }
Ejemplo n.º 17
0
        private void initData()
        {
            DataTable dt = bRerceipt.GetOtherList(_slip_number).Tables[0];

            try
            {
                txtSupplierCode.Text  = dt.Rows[0]["SUPPLIER_CODE"].ToString();
                txtSupplierName.Text  = dt.Rows[0]["SUPPLIER_NAME"].ToString();
                txtWarehouseCode.Text = dt.Rows[0]["RECEIPT_WAREHOUSE_CODE"].ToString();
                txtWarehouseName.Text = dt.Rows[0]["WAREHOUSE_NAME"].ToString();
                slipDate.Value        = CConvert.ToDateTime(dt.Rows[0]["SLIP_DATE"]);
                foreach (DataRow dr in CCacheData.Taxation.Rows)
                {
                    if (CConvert.ToDecimal(dr["TAX_RATE"]) == CConvert.ToDecimal(dt.Rows[0]["TAX_RATE"]) * 100)
                    {
                        this.cboTax.SelectedValue = dr["CODE"];
                        break;
                    }
                }
                foreach (DataRow rows in dt.Rows)
                {
                    int             currentRowIndex = dgvData.Rows.Add(1);
                    DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                    row.Cells[1].Selected                  = false;
                    row.Cells["NO"].Value                  = rows["LINE_NUMBER"];
                    row.Cells["PRODUCT_CODE"].Value        = rows["PRODUCT_CODE"];
                    row.Cells["NAME"].Value                = rows["PRODUCT_NAME"];
                    row.Cells["SPEC"].Value                = rows["SPEC"];
                    row.Cells["QUANTITY"].Value            = rows["QUANTITY"];
                    row.Cells["UNIT_NAME"].Value           = rows["UNIT_NAME"];
                    row.Cells["UNIT_CODE"].Value           = rows["UNIT_CODE"];
                    row.Cells["PRICE"].Value               = rows["PRICE"];
                    row.Cells["AMOUNT"].Value              = rows["AMOUNT_WITHOUT_TAX"];
                    row.Cells["AMOUNT_INCLUDED_TAX"].Value = rows["AMOUNT_INCLUDED_TAX"];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BaseTechnologyTable GetModel(string CODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from base_technology_view ");
            strSql.Append(" where CODE=@CODE ");
            strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE);
            SqlParameter[] parameters =
            {
                new SqlParameter("@CODE", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = CODE;

            BaseTechnologyTable model = new BaseTechnologyTable();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.CODE = ds.Tables[0].Rows[0]["CODE"].ToString();
                model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
                model.TECHNOLOGY_DRAWING1 = ds.Tables[0].Rows[0]["TECHNOLOGY_DRAWING1"].ToString();
                model.TECHNOLOGY_DRAWING2 = ds.Tables[0].Rows[0]["TECHNOLOGY_DRAWING2"].ToString();
                model.TECHNOLOGY_DRAWING3 = ds.Tables[0].Rows[0]["TECHNOLOGY_DRAWING3"].ToString();
                model.PERIOD                  = CConvert.ToInt32(ds.Tables[0].Rows[0]["PERIOD"].ToString());
                model.STATUS_FLAG             = CConvert.ToInt32(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString());
                model.LAST_UPDATE_USER        = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString();
                model.LAST_UPDATE_TIME        = CConvert.ToDateTime(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString());
                model.DEPARTMENT_CODE         = ds.Tables[0].Rows[0]["DEPARTMENT_CODE"].ToString();
                model.CREATE_USER             = ds.Tables[0].Rows[0]["CREATE_USER"].ToString();
                model.CREATE_DATE_TIME        = CConvert.ToDateTime(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString());
                model.DEPARTMENT_NAME         = ds.Tables[0].Rows[0]["DEPARTMENT_NAME"].ToString();
                model.TECHNOLOGY_DRAWINGNAME1 = ds.Tables[0].Rows[0]["DRAWING_NAME1"].ToString();
                model.TECHNOLOGY_DRAWINGNAME2 = ds.Tables[0].Rows[0]["DRAWING_NAME2"].ToString();
                model.TECHNOLOGY_DRAWINGNAME3 = ds.Tables[0].Rows[0]["DRAWING_NAME3"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentExchangeTable == null)
                {
                    _currentExchangeTable = new BaseExchangeTable();
                }

                _currentExchangeTable.EXCHANGE_DATE      = CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM"));
                _currentExchangeTable.FROM_CURRENCY_CODE = txtCurrencyCode.Text;
                _currentExchangeTable.TO_CURRENCY_CODE   = CConstant.EXCHANGE_CHIAN;
                _currentExchangeTable.EXCHANGE_RATE      = CConvert.ToDecimal(txtExchangeRate.Text);
                _currentExchangeTable.LAST_UPDATE_USER   = _userInfo.CODE;

                try
                {
                    if (bExchange.Exists(ExchangeDate.Value, txtCurrencyCode.Text.Trim()))
                    {
                        bExchange.Update(_currentExchangeTable);
                    }
                    else
                    {
                        _currentExchangeTable.CREATE_USER = _userInfo.CODE;
                        bExchange.Add(_currentExchangeTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show(ex.Message);
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Ejemplo n.º 20
0
        public void ReceiptList(int currentPage)
        {
            DataSet ds = bStock.GetReceiptList(warehousecode, productcode, (currentPage - 1) * PageSize + 1, currentPage * PageSize);

            dgvData.Rows.Clear();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                int             currentRowIndex = dgvData.Rows.Add(1);
                DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                row.Cells[1].Selected             = false;
                row.Cells["WAREHOUSE_CODE"].Value = CConvert.ToString(dr["RECEIPT_WAREHOUSE_CODE"]);
                row.Cells["WAREHOUSE_NAME"].Value = CConvert.ToString(dr["WAREHOUSE_NAME"]);
                row.Cells["PRODUCT_CODE"].Value   = CConvert.ToString(dr["PRODUCT_CODE"]);
                row.Cells["PRODUCT_NAME"].Value   = CConvert.ToString(dr["PRODUCT_NAME"]);
                row.Cells["NAME"].Value           = CConvert.ToString(dr["SUPPLIER_NAME"]);
                row.Cells["DUE_DATE"].Value       = CConvert.ToDateTime(dr["DUE_DATE"]).ToString("yyyy-MM-dd");
                row.Cells["SLIP_NUMBER"].Value    = CConvert.ToString(dr["PURCHASE_ORDER_SLIP_NUMBER"]);
                row.Cells["QUANTITY"].Value       = CConvert.ToDecimal(dr["RECEIPT_PLAN_QUANTITY"]);
            }
            if (ds.Tables[0].Rows.Count < PageSize)
            {
                dgvData.Rows.Add(PageSize - ds.Tables[0].Rows.Count);
            }
        }
Ejemplo n.º 21
0
        private void txtCurrencyCode_Leave(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtCurrencyCode.Text.Trim()))
            {
                BaseMaster baseMaster = bCommon.GetBaseMaster("CURRENCY", txtCurrencyCode.Text.Trim());
                if (baseMaster != null)
                {
                    txtCurrencyCode.Text = baseMaster.Code;
                    txtCurrencyName.Text = baseMaster.Name;
                }
                else
                {
                    MessageBox.Show("货币不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtCurrencyCode.Text = "";
                    txtCurrencyName.Text = "";
                    txtCurrencyCode.Focus();
                }
            }
            else
            {
                txtCurrencyName.Text = "";
            }

            if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim()) && ExchangeDate.Value != null)
            {
                BaseExchangeTable exchange = new BaseExchangeTable();
                exchange = bExchange.GetModel(CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")), txtCurrencyCode.Text);
                if (exchange != null)
                {
                    ExchangeDate.Value   = DateTime.Now;
                    txtCurrencyCode.Text = "";
                    ExchangeDate.Focus();
                    MessageBox.Show("当月此货币汇率已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 导出
        /// </summary>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCompanyCode.Text))
            {
                MessageBox.Show("请选择公司。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrEmpty(txtFilePath.Text))
            {
                MessageBox.Show("请选择保存路径。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            BaseCompanyTable    companyTable  = bCompany.GetModel(txtCompanyCode.Text.Trim());
            BllOrderHeaderTable orderTable    = bOrderH.GetModel(_slipNumber);
            BaseCustomerTable   customerTable = bCustomer.GetModel(orderTable.ENDER_CUSTOMER_CODE);

            report.Preview = previewControl1;
            DataTable dt = new DataTable();

            dt.TableName = "ds";
            dt.Columns.Add("i", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("SPEC", System.Type.GetType("System.String"));
            dt.Columns.Add("QUANTITY", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("PRICE", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("DISCOUNT", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("AMOUNT", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("MATERIAL", System.Type.GetType("System.String"));
            dt.Columns.Add("MEMO", System.Type.GetType("System.String"));
            dt.Columns.Add("DESCRIPTION", System.Type.GetType("System.String"));
            dt.Columns.Add("DESCRIPTION1", System.Type.GetType("System.String"));
            int j = 1;

            foreach (BllOrderLineTable lineModel in orderTable.Items)
            {
                if (lineModel.PRICE_DISCOUNT.ToString().Equals("0.00"))
                {
                    object[] rows = { j++, lineModel.SPEC, lineModel.QUANTITY, lineModel.PRICE, null, lineModel.AMOUNT, lineModel.METERIAL, lineModel.MEMO, lineModel.DESCRIPTION, lineModel.DESCRIPTION1 };

                    dt.Rows.Add(rows);
                }
                else
                {
                    object[] rows = { j++, lineModel.SPEC, lineModel.QUANTITY, lineModel.PRICE, 0 - lineModel.PRICE_DISCOUNT, lineModel.AMOUNT, lineModel.METERIAL, lineModel.MEMO, lineModel.DESCRIPTION, lineModel.DESCRIPTION1 };
                    dt.Rows.Add(rows);
                }
            }

            DataSet ds = new DataSet();

            ds.Tables.Add(dt);

            string fileName   = "";
            string amountName = "";

            if (CConstant.LANGUAGE_CN.Equals(cboLanguage.SelectedValue))
            {
                fileName   = @"Reports\Proforma_Invoice.frx";
                amountName = NumberConvert.NumberToEnglish(CConvert.ToString(orderTable.AMOUNT_INCLUDED_TAX), false);
            }
            else if (CConstant.LANGUAGE_EN.Equals(cboLanguage.SelectedValue))
            {
                fileName   = @"Reports\Order_EN.frx";
                amountName = NumberConvert.NumberToEnglish(CConvert.ToString(orderTable.AMOUNT_INCLUDED_TAX), false);
            }

            try
            {
                if (File.Exists(fileName))
                {
                    report.Load(fileName);
                    report.SetParameterValue("CompanyName", companyTable.NAME);
                    report.SetParameterValue("EnglishCompanyName", companyTable.NAME_ENGLISH);
                    report.SetParameterValue("CompanyTel", companyTable.PHONE_NUMBER);
                    report.SetParameterValue("CompanyFax", companyTable.FAX_NUMBER);
                    report.SetParameterValue("CompanyAddress", companyTable.ADDRESS_MIDDLE);
                    report.SetParameterValue("CompanyUrl", companyTable.URL);
                    report.SetParameterValue("CompanyEmail", companyTable.EMAIL);
                    report.SetParameterValue("SlipNumber", _slipNumber);
                    report.SetParameterValue("SlipDate", CConvert.ToDateTime(orderTable.SLIP_DATE).ToString("yyyy/MM/dd"));
                    report.SetParameterValue("Currency", orderTable.CURRENCY_NAME);
                    report.SetParameterValue("CustomerName", customerTable.NAME);
                    int COUNT = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr["DISCOUNT"].ToString() != "")
                        {
                            COUNT++;
                        }
                    }
                    if (COUNT > 0)
                    {
                        report.SetParameterValue("DISCOUNT", "Discount");
                    }

                    if (customerTable.PHONE_NUMBER.ToString() != "")
                    {
                        report.SetParameterValue("CustomerTel", "Tel:" + customerTable.PHONE_NUMBER);
                    }
                    if (customerTable.FAX_NUMBER.ToString() != "")
                    {
                        report.SetParameterValue("CustomerFax", "Fax:" + customerTable.FAX_NUMBER);
                    }
                    if (customerTable.ADDRESS_FIRST.ToString() != "")
                    {
                        report.SetParameterValue("CustomerAddress", "Address:" + customerTable.ADDRESS_FIRST);
                    }
                    report.SetParameterValue("CustomerMessage", txtMessage.Text);
                    report.SetParameterValue("DeliveryTerms", orderTable.DELIVERY_TERMS);
                    report.SetParameterValue("PaymentTerms", orderTable.PAYMENT_TERMS);
                    if (orderTable.DISCOUNT_RATE > 0)
                    {
                        report.SetParameterValue("DiscountRate", "-" + orderTable.DISCOUNT_RATE + "%");
                        report.SetParameterValue("DiscountAmount", orderTable.AMOUNT_INCLUDED_TAX);
                    }
                    report.SetParameterValue("AmountName", amountName);

                    report.SetParameterValue("FullNameEn", txtBankEn.Text);
                    report.SetParameterValue("DetailEn", rtxtDetail.Text);
                    if (companyTable.COMPANY_PICTURE != null)
                    {
                        MemoryStream ms    = new MemoryStream((byte[])companyTable.COMPANY_PICTURE);
                        Image        image = Image.FromStream(ms);
                        ((FastReport.PictureObject)report.FindObject("CompanyPicture")).Image = image;
                    }
                    if (companyTable.LOGO != null)
                    {
                        MemoryStream ms1    = new MemoryStream((byte[])companyTable.LOGO);
                        Image        image1 = Image.FromStream(ms1);
                        ((FastReport.PictureObject)report.FindObject("Logo")).Image = image1;
                    }
                    report.RegisterData(ds);
                    report.Prepare();
                    if (fileName.Equals(@"Reports\Proforma_Invoice.frx"))
                    {
                        report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Proforma_Invoice" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf");
                    }
                    else
                    {
                        report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Order_" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf");
                    }
                    MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }

            catch (Exception ex)
            {
                Logger.Error("", ex);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 计算
        /// </summary>
        private void btnCal_Click(object sender, EventArgs e)
        {
            //当月的采购数据
            #region
            string where = " BP.SLIP_DATE >='" + txtDateTime.Value.ToString("yyyy/MM/01") + "' AND BP.SLIP_DATE <'" + txtDateTime.Value.AddMonths(1).ToString("yyyy/MM/01") + "' ";
            DataTable purchaseDt = bInvoice.GetPurchaseInfo(where).Tables[0];
            //销售数据的整理,外币的转换
            DataTable pDt = purchaseDt.Clone();
            DataRow   pDr = null;
            string    currentProductCode = "";
            foreach (DataRow dr in purchaseDt.Rows)
            {
                decimal exchange     = 1;
                string  currencyCode = CConvert.ToString(dr["CURRENCY_CODE"]);
                if (!CConstant.EXCHANGE_RMB.Equals(currencyCode))
                {
                    exchange = bExchange.GetExchange(CConvert.ToDateTime(txtDateTime.Value.ToString("yyyy/MM/01")), currencyCode, CConstant.EXCHANGE_RMB);
                }

                //总金额=发票金额*汇率+税+包装金额*汇率
                decimal amount = CConvert.ToDecimal(dr["INVOICE_AMOUNT"]) * exchange + CConvert.ToDecimal(dr["TAX_AMOUNT"]) + CConvert.ToDecimal(dr["PACKING_AMOUNT"]) * exchange;

                string productCode = CConvert.ToString(dr["PRODUCT_CODE"]);
                if (currentProductCode != productCode)
                {
                    if (!string.IsNullOrEmpty(currentProductCode))
                    {
                        pDt.Rows.Add(pDr);
                    }
                    currentProductCode = productCode;
                    pDr = pDt.NewRow();
                    pDr["RECEIPT_WAREHOUSE_CODE"] = dr["RECEIPT_WAREHOUSE_CODE"];
                    pDr["PRODUCT_CODE"]           = dr["PRODUCT_CODE"];
                    pDr["QUANTITY"]       = dr["QUANTITY"];
                    pDr["INVOICE_AMOUNT"] = amount;
                }
                else
                {
                    pDr["INVOICE_AMOUNT"] = CConvert.ToDecimal(pDr["INVOICE_AMOUNT"]) + amount;
                    pDr["QUANTITY"]       = CConvert.ToDecimal(pDr["QUANTITY"]) + CConvert.ToDecimal(dr["QUANTITY"]);
                }
            }
            if (pDr != null)
            {
                pDt.Rows.Add(pDr);
            }
            #endregion

            //当月的销售数据
            where = " BS.SLIP_DATE >='" + txtDateTime.Value.ToString("yyyy/MM/01") + "' AND BS.SLIP_DATE <'" + txtDateTime.Value.AddMonths(1).ToString("yyyy/MM/01") + "' ";
            DataTable salesDt = bInvoice.GetSalesInfo(where).Tables[0];

            //上个月的月末数据
            where = " YEAR_MONTH ='" + txtDateTime.Value.AddMonths(-1).ToString("yyyyMM") + "' ";
            DataTable previousMonthStockDt = bInvoice.GetPreviousMonthStockData(where).Tables[0];

            //上个月存在的数据的整理
            #region
            DataTable insertDt = previousMonthStockDt.Clone();
            DataRow   insertDr = null;
            foreach (DataRow dr in previousMonthStockDt.Rows)
            {
                insertDr                      = insertDt.NewRow();
                insertDr["YEAR"]              = txtDateTime.Value.ToString("yyyy");
                insertDr["MONTH"]             = txtDateTime.Value.ToString("MM");
                insertDr["YEAR_MONTH"]        = txtDateTime.Value.ToString("yyyyMM");
                insertDr["WAREHOUSE_CODE"]    = dr["WAREHOUSE_CODE"];
                insertDr["PRODUCT_CODE"]      = dr["PRODUCT_CODE"];
                insertDr["PREVIOUS_AMOUNT"]   = dr["AMOUNT"];
                insertDr["PREVIOUS_QUANTITY"] = dr["STOCK"];
                insertDr["PREVIOUS_PRICE"]    = dr["PRICE"];
                foreach (DataRow purchaseDr in purchaseDt.Rows)
                {
                    if (CConvert.ToString(purchaseDr["PRODUCT_CODE"]).Equals(dr["PRODUCT_CODE"]))
                    {
                        insertDr["PURCHASE_QUANTITY"] = purchaseDr["QUANTITY"];
                        insertDr["PURCHASE_AMOUNT"]   = purchaseDr["INVOICE_AMOUNT"];
                        purchaseDt.Rows.Remove(purchaseDr);
                        break;
                    }
                }
                foreach (DataRow sDr in salesDt.Rows)
                {
                    if (CConvert.ToString(sDr["PRODUCT_CODE"]).Equals(dr["PRODUCT_CODE"]))
                    {
                        insertDr["SALES_QUANTITY"] = sDr["QUANTITY"];
                        salesDt.Rows.Remove(sDr);
                        break;
                    }
                }
                decimal price = 0;
                try
                {
                    price = (CConvert.ToDecimal(insertDr["PREVIOUS_AMOUNT"]) + CConvert.ToDecimal(insertDr["PURCHASE_AMOUNT"])) / (CConvert.ToDecimal(insertDr["PREVIOUS_QUANTITY"]) + CConvert.ToDecimal(insertDr["PURCHASE_AMOUNT"]));
                }
                catch (Exception ex) { }
                insertDr["PRICE"]            = price;
                insertDr["SALES_AMOUNT"]     = price * CConvert.ToDecimal(insertDr["SALES_QUANTITY"]);
                insertDr["STOCK"]            = CConvert.ToDecimal(insertDr["PREVIOUS_QUANTITY"]) + CConvert.ToDecimal(insertDr["PURCHASE_QUANTITY"]) - CConvert.ToDecimal(insertDr["SALES_QUANTITY"]);
                insertDr["AMOUNT"]           = price * CConvert.ToDecimal(insertDr["STOCK"]);
                insertDr["STATUS_FLAG"]      = CConstant.INIT_STATUS;
                insertDr["CREATE_USER"]      = UserTable.CODE;
                insertDr["LAST_UPDATE_USER"] = UserTable.CODE;
                insertDt.Rows.Add(insertDr);
            }
            #endregion


            //当月采购数据的整理
            #region
            foreach (DataRow purchaseDr in purchaseDt.Rows)
            {
                insertDr                      = insertDt.NewRow();
                insertDr["YEAR"]              = txtDateTime.Value.ToString("yyyy");
                insertDr["MONTH"]             = txtDateTime.Value.ToString("MM");
                insertDr["YEAR_MONTH"]        = txtDateTime.Value.ToString("yyyyMM");
                insertDr["WAREHOUSE_CODE"]    = purchaseDr["RECEIPT_WAREHOUSE_CODE"];
                insertDr["PRODUCT_CODE"]      = purchaseDr["PRODUCT_CODE"];
                insertDr["PREVIOUS_AMOUNT"]   = 0;
                insertDr["PREVIOUS_QUANTITY"] = 0;
                insertDr["PREVIOUS_PRICE"]    = 0;
                insertDr["PURCHASE_QUANTITY"] = purchaseDr["QUANTITY"];
                insertDr["PURCHASE_AMOUNT"]   = purchaseDr["INVOICE_AMOUNT"];
                foreach (DataRow sDr in salesDt.Rows)
                {
                    if (CConvert.ToString(sDr["PRODUCT_CODE"]).Equals(purchaseDr["PRODUCT_CODE"]))
                    {
                        insertDr["SALES_QUANTITY"] = sDr["QUANTITY"];
                        salesDt.Rows.Remove(sDr);
                        break;
                    }
                }
                decimal price = 0;
                try
                {
                    price = (CConvert.ToDecimal(insertDr["PREVIOUS_AMOUNT"]) + CConvert.ToDecimal(insertDr["PURCHASE_AMOUNT"])) / (CConvert.ToDecimal(insertDr["PREVIOUS_QUANTITY"]) + CConvert.ToDecimal(insertDr["PURCHASE_AMOUNT"]));
                }
                catch (Exception ex) { }
                insertDr["PRICE"]            = price;
                insertDr["SALES_AMOUNT"]     = price * CConvert.ToDecimal(insertDr["SALES_QUANTITY"]);
                insertDr["STOCK"]            = CConvert.ToDecimal(insertDr["PREVIOUS_QUANTITY"]) + CConvert.ToDecimal(insertDr["PURCHASE_QUANTITY"]) - CConvert.ToDecimal(insertDr["SALES_QUANTITY"]);
                insertDr["AMOUNT"]           = price * CConvert.ToDecimal(insertDr["STOCK"]);
                insertDr["STATUS_FLAG"]      = CConstant.INIT_STATUS;
                insertDr["CREATE_USER"]      = UserTable.CODE;
                insertDr["LAST_UPDATE_USER"] = UserTable.CODE;
                insertDt.Rows.Add(insertDr);
            }
            #endregion

            try
            {
                if (bInvoice.AddMonthlyStock(insertDt) > 0)
                {
                    MessageBox.Show("计算完成!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //this.Close();
                }
                else
                {
                    MessageBox.Show("计算失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("计算失败,请重试或与系统管理员联系!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Logger.Error("月末计算:", ex);
            }
        }
Ejemplo n.º 24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (saveCheck())
            {
                int result = 0;

                //  保存成功件数
                int successCount = 0;
                // 保存失败件数
                int erroeCount = 0;

                BllPaymentMatchTable payment = null;
                foreach (DataGridViewRow row in dgvData.Rows)
                {
                    // 预付款金额
                    decimal depositAmount = CConvert.ToDecimal(CConvert.ToString(row.Cells["DEPOSIT_AMOUNT"].Value));

                    //其他金额
                    decimal otherAmount = CConvert.ToDecimal(CConvert.ToString(row.Cells["OTHER_AMOUNT"].Value));

                    //收款总金额
                    decimal totalAmount = depositAmount + otherAmount;

                    payment                      = new BllPaymentMatchTable();
                    payment.SLIP_DATE            = CConvert.ToDateTime(row.Cells["SLIP_DATE"].Value);
                    payment.PURCHASE_SLIP_NUMBER = CConvert.ToString(row.Cells["SLIP_NUMBER"].Value);
                    payment.TOTAL_AMOUNT         = totalAmount;
                    payment.DEPOSIT_AMOUNT       = depositAmount;
                    payment.OTHER_AMOUNT         = otherAmount;
                    payment.COMPANY_CODE         = _userInfo.COMPANY_CODE;
                    payment.STATUS_FLAG          = CConstant.INIT;
                    payment.CREATE_USER          = _userInfo.CODE;
                    payment.CREATE_DATE_TIME     = DateTime.Now;
                    payment.LAST_UPDATE_USER     = _userInfo.CODE;
                    payment.LAST_UPDATE_TIME     = DateTime.Now;

                    try
                    {
                        result = bPayemntMatch.AddpaymentMatch(payment);
                        if (result > 0)
                        {
                            successCount = successCount + 1;
                        }
                        else
                        {
                            erroeCount = erroeCount + 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        Logger.Error("收款金额输入保存失败!!!!!", ex);
                    }
                }

                if (successCount > 0 && erroeCount == 0)
                {
                    MessageBox.Show("付款输入保存成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    initPage();
                }

                else if (successCount > 0 && erroeCount > 0)
                {
                    MessageBox.Show("付款保存部分失败!请与系统管理员联系!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    initPage();
                }

                else if (successCount == 0 && erroeCount > 0)
                {
                    MessageBox.Show("付款保存失败!请与系统管理员联系!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    initPage();
                }
            }
        }
Ejemplo n.º 25
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckHeaderInput())
            {
                return;
            }

            if (!CheckLineInput())
            {
                return;
            }

            BllPurchaseOrderTable     POTable = new BllPurchaseOrderTable();
            BllPurchaseOrderLineTable OLTable = null;

            //订单类型
            POTable.SLIP_TYPE = cboPurchaseSlipType.SelectedValue.ToString();
            //订单编号
            POTable.SLIP_NUMBER = txtPurchaseSlipNumber.Text.Trim();
            //类型编号
            POTable.ORDER_SLIP_NUMBER = txtOrderNumber.Text.Trim();
            //供应商编号
            POTable.SUPPLIER_CODE = txtSupplierCode.Text.Trim();
            //报价单号
            POTable.SUPPLIER_ORDER_NUMBER = txtSupplierOrderCode.Text.Trim();
            //入库仓库
            POTable.RECEIPT_WAREHOUSE_CODE = txtWarehouseCode.Text.Trim();
            //采购订单日期
            POTable.SLIP_DATE = CConvert.ToDateTime(entryDate.Value.ToString("yyyy-MM-dd"));
            //交货期限
            POTable.DUE_DATE = CConvert.ToDateTime(dueDate.Value.ToString("yyyy-MM-dd"));
            //税率
            POTable.TAX_RATE = CConvert.ToDecimal(cboTax.Text.Replace("%", "")) / 100;
            //通货
            POTable.CURRENCY_CODE = "01";
            //包装方式
            //POTable.PACKING_METHOD = txtPackingMethod.Text.Trim();
            //付款方式
            POTable.PAYMENT_CONDITION = txtPayment.Text.Trim();
            //备注
            POTable.MEMO = txtMemo.Text.Trim();
            //状态
            POTable.STATUS_FLAG = CConstant.PURCHASE_NEW;
            //创建人
            POTable.CREATE_USER = UserTable.CODE;
            //最后更新人
            POTable.LAST_UPDATE_USER = UserTable.CODE;
            //公司
            POTable.COMPANY_CODE = UserTable.COMPANY_CODE;
            //总金额
            POTable.TOTAL_AMOUNT = CConvert.ToDecimal(txtAmountIncludedTax.Text.Trim());
            //明细的整理
            foreach (DataGridViewRow row in dgvData.Rows)
            {
                OLTable                     = new BllPurchaseOrderLineTable();
                OLTable.SLIP_NUMBER         = POTable.SLIP_NUMBER;
                OLTable.LINE_NUMBER         = row.Index + 1;
                OLTable.PRODUCT_CODE        = row.Cells["PRODUCT_CODE"].Value.ToString();
                OLTable.QUANTITY            = CConvert.ToDecimal(row.Cells["QUANTITY"].Value.ToString());
                OLTable.UNIT_CODE           = row.Cells["UNIT_CODE"].Value.ToString();
                OLTable.PRICE               = CConvert.ToDecimal(row.Cells["PRICE"].Value.ToString());
                OLTable.AMOUNT_WITHOUT_TAX  = CConvert.ToDecimal(row.Cells["AMOUNT"].Value.ToString());
                OLTable.AMOUNT_INCLUDED_TAX = CConvert.ToDecimal(row.Cells["AMOUNT_INCLUDED_TAX"].Value.ToString());
                OLTable.TAX_AMOUNT          = OLTable.AMOUNT_INCLUDED_TAX - OLTable.AMOUNT_WITHOUT_TAX;
                OLTable.STATUS_FLAG         = CConstant.PURCHASE_NEW;
                POTable.AddItem(OLTable);
            }

            int result = 0;

            try
            {
                if (_currentPurchaseOrderTable != null)
                {
                    result = bPurchaseOrder.Update(POTable);
                }
                else
                {
                    result = bPurchaseOrder.Add(POTable);
                }

                if (result <= 0)
                {
                    MessageBox.Show("订单保存失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("订单保存成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (CConstant.PURCHASE_ORDER_NEW.Equals(CTag))
                    {
                        initPage();
                    }
                    else
                    {
                        _dialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("订单保存失败,系统错误,请与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Logger.Error("订单保存失败!", ex);
            }
        }
Ejemplo n.º 26
0
        public override string[] doUpdateDB()
        {
            BaseCustomerReportedTable CustomerReportedTable = null;
            BCustomerReported         bCustomerReported     = new BCustomerReported();
            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(CheckCustomer(CConvert.ToString(GetValue(dr, "CUSTOMER_CODE")), "客户编号"));
                //报备客户名称
                str.Append(CheckCustomer(CConvert.ToString(GetValue(dr, "CUSTOMER_REPORTED_CODE")), "报备客户名称"));
                //报备日期
                str.Append(CheckDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now), "报备日期"));
                //有效日期
                str.Append(CheckDateTime(GetValue(dr, "EFFECTIVE_DATE", DateTime.Now.AddMonths(3)), "有效日期"));
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态"));
                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    CustomerReportedTable = new BaseCustomerReportedTable();
                    CustomerReportedTable.CUSTOMER_CODE          = CConvert.ToString(GetValue(dr, "CUSTOMER_CODE"));
                    CustomerReportedTable.CUSTOMER_REPORTED_CODE = CConvert.ToString(GetValue(dr, "CUSTOMER_REPORTED_CODE"));
                    CustomerReportedTable.REPORTED_DATE          = CConvert.ToDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now));
                    CustomerReportedTable.CREATE_USER            = _userInfo.CODE;
                    CustomerReportedTable.LAST_UPDATE_USER       = _userInfo.CODE;
                    if (CConvert.ToDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now)) != DateTime.Now)
                    {
                        CustomerReportedTable.EFFECTIVE_DATE = CConvert.ToDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now)).AddMonths(3);
                    }
                    else
                    {
                        CustomerReportedTable.EFFECTIVE_DATE = CConvert.ToDateTime(GetValue(dr, "EFFECTIVE_DATE", DateTime.Now.AddMonths(3)));
                    }
                    CustomerReportedTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));

                    if (!bCustomerReported.Exists(CustomerReportedTable.CUSTOMER_CODE, CustomerReportedTable.CUSTOMER_REPORTED_CODE))
                    {
                        bCustomerReported.Add(CustomerReportedTable);
                    }
                    else
                    {
                        bCustomerReported.Update(CustomerReportedTable);
                    }
                    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 });
        }
Ejemplo n.º 27
0
        private void FrmProductionPlanDetails_Load(object sender, EventArgs e)
        {
            this.WindowState           = FormWindowState.Normal;
            this.Tag                   = CTag;
            txtProductionQuantity.Text = _plan_quantity.ToString();
            textBox2.Text              = planTable.SLIP_TYPE_NAME;
            textBox3.Text              = _parts_name;
            textBox1.Text              = planTable.SPEC;
            txtSlipDateFrom.Value      = _plan_start_time;
            txtDepartualDateFrom.Value = _plan_end_time;
            if (CConstant.PRODUCTIONPLAN_OPERATE.Equals(CTag))
            {
                dgvData.Columns["START_DATE"].ReadOnly       = true;
                dgvData.Columns["END_DATE"].ReadOnly         = true;
                dgvData.Columns["PRODUCTION_CYCLE"].ReadOnly = true;
                this.btnAddProductionProcess.Visible         = false;
                this.btnSave.Visible = false;
                this.btnDown.Visible = false;
                this.btnUp.Visible   = false;
            }

            else if (CConstant.PRODUCTIONPLAN_MODIFY.Equals(CTag))
            {
                dgvData.Columns["START_DATE"].ReadOnly = true;
                dgvData.Columns["END_DATE"].ReadOnly   = true;
                this.btnAddProductionProcess.Visible   = false;
                //this.btnSave.Visible = false;
                this.btnDown.Visible = false;
                this.btnUp.Visible   = false;
            }

            foreach (BaseProductionPlanLineTable lineTable in planTable.Items)
            {
                if (lineTable.PARTS_CODE == PARTS_CODE)
                {
                    foreach (BaseProductionScheduleProductionProcessTable productionProcessTable in lineTable.ProductionProcess)
                    {
                        object[] dgvr = { "", productionProcessTable.PRODUCTION_PROCESS_CODE, productionProcessTable.PRODUCTION_PROCESS_NAME, productionProcessTable.DEPARTMENT_CODE, productionProcessTable.DEPARTMENT_NAME, productionProcessTable.PLAN_START_DATE, productionProcessTable.PLAN_END_DATE, productionProcessTable.STATUS_FLAG };
                        dgvData.Rows.Add(dgvr);
                    }
                }
            }
            foreach (DataGridViewRow dr in dgvData.Rows)
            {
                string   dateDiff = null;
                TimeSpan ts1      = new TimeSpan(CConvert.ToDateTime(CConvert.ToDateTime(dr.Cells["START_DATE"].Value).ToShortDateString()).Ticks);
                TimeSpan ts2      = new TimeSpan(CConvert.ToDateTime(CConvert.ToDateTime(dr.Cells["END_DATE"].Value).ToShortDateString()).Ticks);
                TimeSpan ts       = ts1.Subtract(ts2).Duration();
                dateDiff = ts.Days.ToString();
                dr.Cells["PRODUCTION_CYCLE"].Value = CConvert.ToInt32(dateDiff);
                if (CConstant.PRODUCTIONPLAN_OPERATE.Equals(CTag) || CConstant.PRODUCTIONPLAN_MODIFY.Equals(CTag))
                {
                    if (CConvert.ToInt32(dr.Cells["FLAG"].Value).Equals(2))
                    {
                        dr.Cells["STATUS_FLAG"].Value         = "已结束";
                        dr.Cells["PRODUCTION_CYCLE"].ReadOnly = true;
                    }
                    else
                    {
                        dr.Cells["STATUS_FLAG"].Value = "未结束";
                    }
                }
            }
        }
Ejemplo n.º 28
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (dgvData.Rows.Count < 1)
     {
         MessageBox.Show("工序不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     foreach (DataGridViewRow dr in dgvData.Rows)
     {
         if (CConvert.ToDateTime(CConvert.ToDateTime(dr.Cells["END_DATE"].Value).ToShortDateString()) > CConvert.ToDateTime(CConvert.ToDateTime(planTable.PLAN_END_DATE).ToShortDateString()))
         {
             if (DialogResult.OK == MessageBox.Show("此部件预定日期超出此工单预定完成日期,确定要调整吗,确定后不能返回?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
             {
                 foreach (BaseProductionPlanLineTable lineTable in planTable.Items)
                 {
                     if (lineTable.PARTS_CODE == PARTS_CODE)
                     {
                         lineTable.ProductionProcess.Clear();
                         lineTable.PLAN_START_DATE = CConvert.ToDateTime(dgvData.Rows[0].Cells["START_DATE"].Value.ToString());
                         lineTable.PLAN_END_DATE   = CConvert.ToDateTime(dgvData.Rows[dgvData.Rows.Count - 1].Cells["END_DATE"].Value.ToString());
                         int ProductionProcessLineNumber = 1;
                         foreach (DataGridViewRow dr2 in dgvData.Rows)
                         {
                             BaseProductionScheduleProductionProcessTable productionProcessTable = new BaseProductionScheduleProductionProcessTable();
                             productionProcessTable.PRODUCTION_PROCESS_CODE = CConvert.ToString(dr2.Cells["PRODUCTION_PROCESS_CODE"].Value);
                             productionProcessTable.PRODUCTION_PROCESS_NAME = CConvert.ToString(dr2.Cells["PRODUCTION_PROCESS_NAME"].Value);
                             productionProcessTable.DEPARTMENT_CODE         = CConvert.ToString(dr2.Cells["DEPARTMENT_CODE"].Value);
                             productionProcessTable.DEPARTMENT_NAME         = CConvert.ToString(dr2.Cells["DEPARTMENT_NAME"].Value);
                             productionProcessTable.PLAN_START_DATE         = CConvert.ToDateTime(dr2.Cells["START_DATE"].Value);
                             productionProcessTable.PLAN_END_DATE           = CConvert.ToDateTime(dr2.Cells["END_DATE"].Value);
                             productionProcessTable.LINE_NUMBER             = ProductionProcessLineNumber++;
                             productionProcessTable.SCHEDULE_LINE_NUNBER    = lineTable.LINE_NUMBER;
                             productionProcessTable.PRODUCTION_CYCLE        = CConvert.ToInt32(dr2.Cells["PRODUCTION_CYCLE"].Value);
                             lineTable.AddProductionProcess(productionProcessTable);
                         }
                     }
                 }
                 result = DialogResult.OK;
                 this.Close();
             }
             else
             {
                 dgvData.Rows.Clear();
                 foreach (BaseProductionPlanLineTable lineTable in planTable.Items)
                 {
                     if (lineTable.PARTS_CODE == PARTS_CODE)
                     {
                         foreach (BaseProductionScheduleProductionProcessTable productionProcessTable in lineTable.ProductionProcess)
                         {
                             object[] dgvr = { "", productionProcessTable.PRODUCTION_PROCESS_CODE, productionProcessTable.PRODUCTION_PROCESS_NAME, productionProcessTable.DEPARTMENT_CODE, productionProcessTable.DEPARTMENT_NAME, productionProcessTable.PLAN_START_DATE, productionProcessTable.PLAN_END_DATE, productionProcessTable.STATUS_FLAG };
                             dgvData.Rows.Add(dgvr);
                         }
                     }
                 }
                 foreach (DataGridViewRow dr1 in dgvData.Rows)
                 {
                     string   dateDiff = null;
                     TimeSpan ts1      = new TimeSpan(CConvert.ToDateTime(CConvert.ToDateTime(dr1.Cells["START_DATE"].Value).ToShortDateString()).Ticks);
                     TimeSpan ts2      = new TimeSpan(CConvert.ToDateTime(CConvert.ToDateTime(dr1.Cells["END_DATE"].Value).ToShortDateString()).Ticks);
                     TimeSpan ts       = ts1.Subtract(ts2).Duration();
                     dateDiff = ts.Days.ToString();
                     dr1.Cells["PRODUCTION_CYCLE"].Value = CConvert.ToInt32(dateDiff);
                     if (CConstant.PRODUCTIONPLAN_OPERATE.Equals(CTag) || CConstant.PRODUCTIONPLAN_MODIFY.Equals(CTag))
                     {
                         if (CConvert.ToInt32(dr1.Cells["FLAG"].Value).Equals(2))
                         {
                             dr1.Cells["STATUS_FLAG"].Value         = "已结束";
                             dr1.Cells["PRODUCTION_CYCLE"].ReadOnly = true;
                         }
                         else
                         {
                             dr1.Cells["STATUS_FLAG"].Value = "未结束";
                         }
                     }
                 }
             }
             break;
         }
     }
 }
Ejemplo n.º 29
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int result = 0;

            //  保存成功件数
            int successCount = 0;
            // 保存失败件数
            int erroeCount = 0;

            //信息保存
            foreach (DataGridViewRow dgvr in dgvData.Rows)
            {
                // 预付款金额
                decimal depositAmount = CConvert.ToDecimal(CConvert.ToString(dgvr.Cells["DEPOSIT_AMOUNT"].Value));

                //其他金额
                decimal otherAmount = CConvert.ToDecimal(CConvert.ToString(dgvr.Cells["OTHER_AMOUNT"].Value));

                //收款总金额
                decimal totalAmount = depositAmount + otherAmount;

                if (totalAmount == 0)
                {
                    continue;
                }

                BllReceiptMatchTable bllReceiptMatchTable = new BllReceiptMatchTable();
                //收款单据内部编号
                //后台更新
                //bllReceiptMatchTable.SLIP_NUMBER = 0;

                //收款时间
                bllReceiptMatchTable.SLIP_DATE = CConvert.ToDateTime(dgvr.Cells["SLIP_DATE"].Value);

                //销售内部编号
                bllReceiptMatchTable.SALES_SLIP_NUMBER = CConvert.ToString(dgvr.Cells["SALES_SLIP_NUMBER"].Value);

                //销售内部明细编号(暂不使用,默认更新为:1)
                bllReceiptMatchTable.SALES_LINE_NUMBER = 1;

                //合计收款金额
                bllReceiptMatchTable.TOTAL_AMOUNT = totalAmount;

                //预付款金额
                bllReceiptMatchTable.DEPOSIT_AMOUNT = depositAmount;

                //其他金额
                bllReceiptMatchTable.OTHER_AMOUNT = otherAmount;

                //状态
                bllReceiptMatchTable.STATUS_FLAG = CConstant.INIT;

                // 公司
                bllReceiptMatchTable.COMPANY_CODE = UserTable.COMPANY_CODE;
                try
                {
                    result = bSales.AddBllReceiptMatch(bllReceiptMatchTable);
                    if (result <= 0)
                    {
                        erroeCount = erroeCount + 1;
                    }
                    else
                    {
                        successCount = successCount + 1;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    Logger.Error("收款金额输入保存失败!!!!!", ex);
                }
            }

            //
            if (successCount == 0 && erroeCount == 0)
            {
                MessageBox.Show("请输入收款金额。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (successCount > 0 && erroeCount == 0)
            {
                MessageBox.Show("收款保存成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                initPage();
            }

            else if (successCount > 0 && erroeCount > 0)
            {
                MessageBox.Show("收款保存部分失败!请与系统管理员联系!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                initPage();
            }

            else if (successCount == 0 && erroeCount > 0)
            {
                MessageBox.Show("收款保存失败!请与系统管理员联系!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                initPage();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 执行操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOperate_Click(object sender, EventArgs e)
        {
            if (dgvData.SelectedRows.Count > 0)
            {
                DataGridViewRow row               = dgvData.SelectedRows[0];
                string          slipNumber        = CConvert.ToString(row.Cells["SLIP_NUMBER"].Value);
                string          companyCode       = CConvert.ToString(row.Cells["COMPANY_CODE"].Value);
                decimal         amountIncludedTax = CConvert.ToDecimal(row.Cells["AMOUNT_INCLUDED_TAX"].Value);
                DateTime        slipDate          = CConvert.ToDateTime(row.Cells["SLIP_DATE"].Value);

                //在库引当
                if (CConstant.ORDER_ALLOATION.Equals(CTag) && companyCode.Equals(_userInfo.COMPANY_CODE))
                {
                    FrmBase frm = new FrmAlloation(slipNumber);
                    frm.UserTable = _userInfo;
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        BindData(this.pgControl.GetCurrentPage());
                    }
                    frm.Dispose();
                }
                //修理输入
                else if (CConstant.ORDER_SERVICE.Equals(CTag) && companyCode.Equals(_userInfo.COMPANY_CODE))
                {
                    FrmBase frm = new FrmOrderService(slipNumber);
                    frm.UserTable = _userInfo;
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        BindData(this.pgControl.GetCurrentPage());
                    }
                    frm.Dispose();
                }
                else
                {
                    FrmBase frm = new FrmOrdersEntry(slipNumber);
                    frm.CTag      = CTag;
                    frm.UserTable = _userInfo;
                    //详细信息
                    if (CConstant.ORDER_SEARCH.Equals(CTag))
                    {
                        if (DialogResult.OK == frm.ShowDialog())
                        {
                        }
                        frm.Dispose();
                    }

                    //订单修正
                    else if (CConstant.ORDER_MODIFY.Equals(CTag) && companyCode.Equals(_userInfo.COMPANY_CODE))
                    {
                        //承认后不能修改
                        //if (CConstant.VERIFY.Equals(CConvert.ToInt32(row.Cells["VERIFY_FLAG"].Value)))
                        //{
                        //    MessageBox.Show("订单己经承认,不能修改。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //}
                        if (CConstant.COMPLETE_SHIPMENT.Equals(CConvert.ToInt32(row.Cells["SHIPMENT_FLAG"].Value)))
                        {
                            MessageBox.Show("订单己经出库完了,不能修正。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (CConstant.PART_SHIPMENT.Equals(CConvert.ToInt32(row.Cells["SHIPMENT_FLAG"].Value)))
                        {
                            MessageBox.Show("订单己经有出库,不能修正。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            if (DialogResult.OK == frm.ShowDialog())
                            {
                                BindData(this.pgControl.GetCurrentPage());
                            }
                            frm.Dispose();
                        }
                    }
                    //订单承认
                    else if (CConstant.ORDER_VERIFY.Equals(CTag) && companyCode.Equals(_userInfo.COMPANY_CODE))
                    {
                        if (CConstant.COMPLETE_SHIPMENT.Equals(CConvert.ToInt32(row.Cells["SHIPMENT_FLAG"].Value)))
                        {
                            MessageBox.Show("订单己经出库完了,不能修改承认状态。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (CConstant.PART_SHIPMENT.Equals(CConvert.ToInt32(row.Cells["SHIPMENT_FLAG"].Value)))
                        {
                            MessageBox.Show("订单己经有出库,不能修改承认状态。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (DialogResult.OK == frm.ShowDialog())
                        {
                            BindData(this.pgControl.GetCurrentPage());
                        }
                        frm.Dispose();
                    }
                    //复制订单
                    else if (CConstant.ORDER_COPY.Equals(CTag))
                    {
                        if (DialogResult.OK == frm.ShowDialog())
                        {
                            BindData(this.pgControl.GetCurrentPage());
                        }
                        frm.Dispose();
                    }
                    //详细信息
                    else if (CConstant.ORDER_MASTER_SEARCH.Equals(CTag))
                    {
                        orderTable.SLIP_NUMBER         = slipNumber;
                        orderTable.AMOUNT_INCLUDED_TAX = amountIncludedTax;
                        orderTable.SLIP_DATE           = slipDate;
                        this.DialogResult = DialogResult.OK;
                        frm.Dispose();
                    }
                }
            }
            else
            {
                MessageBox.Show("请先选择一张订单。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }