Beispiel #1
0
        /// <summary>
        /// 读取控件参数值
        /// </summary>
        private void ReadFieldValue()
        {
            if (mlItemID > 0)
            {
                DataTable dtBackUp = ExecuteSQL.CallView(203, "", "ItemID=" + mlItemID, "");
                if (dtBackUp.Rows.Count > 0)
                {
                    DataRow dr             = dtBackUp.Rows[0];
                    string  strItemCode    = LBConverter.ToString(dr["ItemCode"]);
                    string  strK3ItemCode  = LBConverter.ToString(dr["K3ItemCode"]);
                    string  strItemName    = LBConverter.ToString(dr["ItemName"]);
                    string  strItemMode    = LBConverter.ToString(dr["ItemMode"]);
                    decimal dItemRate      = LBConverter.ToDecimal(dr["ItemRate"]);
                    long    lUOMID         = LBConverter.ToInt32(dr["UOMID"]);
                    long    lItemTypeID    = LBConverter.ToInt32(dr["ItemTypeID"]);
                    string  strDescription = LBConverter.ToString(dr["Description"]);
                    bool    bIsForbid      = LBConverter.ToBoolean(dr["IsForbid"]);
                    decimal decprice       = LBConverter.ToDecimal(dr["ItemPrice"]);

                    this.txtK3ItemCode.Text          = strK3ItemCode;
                    this.txtItemCode.Text            = strItemCode;
                    this.txtItemName.Text            = strItemName;
                    this.txtItemMode.Text            = strItemMode;
                    this.txtItemRate.Text            = dItemRate.ToString();
                    this.txtUOMID.SelectedValue      = lUOMID;
                    this.txtItemTypeID.SelectedValue = lItemTypeID;
                    this.txtDescription.Text         = strDescription;
                    this.chkIsForbid.Checked         = bIsForbid;
                    this.txtPrice.Text = decprice.ToString("0.000");
                }
            }
        }
        private void btnApprove_Click(object sender, EventArgs e)
        {
            try
            {
                List <DataRow> lstSelected = ReadSelectedRows();

                int iIsSynCount = 0;
                foreach (DataRow dr in lstSelected)
                {
                    if (LBConverter.ToBoolean(dr["IsSynchronousToK3OutBill"]) || LBConverter.ToBoolean(dr["IsSynchronousToK3Receive"]))
                    {
                        iIsSynCount++;
                    }
                }

                bool bolIsReSynBill = false;
                if (iIsSynCount > 0)
                {
                    if (LB.WinFunction.LBCommonHelper.ConfirmMessage("选中的单据中存在已同步过的单据,是否继续同步?", "提示", MessageBoxButtons.OKCancel)
                        == DialogResult.OK)
                    {
                        bolIsReSynBill = true;
                    }
                }

                frmSynK3Process frmProcess = new frmSynK3Process(lstSelected, _SynType, bolIsReSynBill);
                LBShowForm.ShowDialog(frmProcess);
                this.LoadAllSalesBill();
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
        public void Delete(FactoryArgs args, t_BigID ModifyBillHeaderID)
        {
            using (DataTable dtHeader = _DALModifyBillHeader.GetModifyBillHeader(args, ModifyBillHeaderID))
            {
                DataRow drHeader     = dtHeader.Rows[0];
                bool    bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
                bool    bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
                if (bolIsApprove)
                {
                    throw new Exception("该调价单已审核,无法删除!");
                }

                if (bolIsCancel)
                {
                    throw new Exception("该调价单已作废,无法删除!");
                }
            }

            DBHelper.ExecInTransDelegate exec = delegate(FactoryArgs argsInTrans)
            {
                using (DataTable dtDetail = _DALModifyBillDetail.GetModifyBillDetailByHeaderID(argsInTrans, ModifyBillHeaderID))
                {
                    foreach (DataRow dr in dtDetail.Rows)
                    {
                    }
                }
                _DALModifyBillHeader.Delete(argsInTrans, ModifyBillHeaderID);
            };
            DBHelper.ExecInTrans(args, exec);
        }
        private void btnReturn_Click(object sender, EventArgs e)
        {
            try
            {
                this.grdMain.EndEdit();
                this.grdMain.CurrentCell = null;
                foreach (DataGridViewRow dgvr in this.grdMain.Rows)
                {
                    bool bolSelected = LBConverter.ToBoolean(dgvr.Cells["LBSelected"].Value);
                    if (bolSelected)
                    {
                        DataRowView drv = dgvr.DataBoundItem as DataRowView;
                        LstReturn.Add(drv.Row);
                    }
                }

                if (LstReturn.Count == 0)
                {
                    throw new Exception("请选择有效的物料行!");
                }
                this.Close();
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Beispiel #5
0
        private static void SetPrintSettings(FastReport.Report report, long lReportTemplateID)
        {
            DataRow   drReport         = null;
            DataTable dtReportTemplate = ReportHelper.GetReportTemplateByID(lReportTemplateID);

            if (dtReportTemplate.Rows.Count > 0)
            {
                drReport = dtReportTemplate.Rows[0];
            }
            //DataTable dtReportTemplate = ExecuteSQL.CallView(105, "", "ReportTemplateID=" + lReportTemplateID, "");
            if (drReport != null)
            {
                //DataRow drReport = dtReportTemplate.Rows[0];
                string strPrinterName    = drReport["PrinterName"].ToString().TrimEnd();
                string strPaperType      = drReport["PaperType"].ToString().TrimEnd();
                int    PaperSizeHeight   = LBConverter.ToInt32(drReport["PaperSizeHeight"]);
                int    PaperSizeWidth    = LBConverter.ToInt32(drReport["PaperSizeWidth"]);
                bool   IsManualPaperType = LBConverter.ToBoolean(drReport["IsManualPaperType"]); //自动识别纸张类型
                bool   IsManualPaperSize = LBConverter.ToBoolean(drReport["IsManualPaperSize"]); //自动识别纸张大小
                bool   IsPaperTransverse = LBConverter.ToBoolean(drReport["IsPaperTransverse"]); //是否纵向打印

                if (strPrinterName != "")
                {
                    report.PrintSettings.Printer = strPrinterName;
                }
            }
        }
Beispiel #6
0
        private void ReadFieldValue()
        {
            DataTable dtCamera = ExecuteSQL.CallView(122, "", "MachineName='" + LoginInfo.MachineName + "'", "");

            if (dtCamera.Rows.Count > 0)
            {
                DataRow dr = dtCamera.Rows[0];
                this.txtIP1.Text       = dr["IPAddress1"].ToString().TrimEnd();
                this.txtPort1.Text     = LBConverter.ToInt32(dr["Port1"]).ToString();
                this.txtAccount1.Text  = dr["Account1"].ToString().TrimEnd();
                this.txtPassword1.Text = dr["Password1"].ToString().TrimEnd();
                this.txtIP2.Text       = dr["IPAddress2"].ToString().TrimEnd();
                this.txtPort2.Text     = LBConverter.ToInt32(dr["Port2"]).ToString();
                this.txtAccount2.Text  = dr["Account2"].ToString().TrimEnd();
                this.txtPassword2.Text = dr["Password2"].ToString().TrimEnd();
                this.txtIP3.Text       = dr["IPAddress3"].ToString().TrimEnd();
                this.txtPort3.Text     = LBConverter.ToInt32(dr["Port3"]).ToString();
                this.txtAccount3.Text  = dr["Account3"].ToString().TrimEnd();
                this.txtPassword3.Text = dr["Password3"].ToString().TrimEnd();
                this.txtIP4.Text       = dr["IPAddress4"].ToString().TrimEnd();
                this.txtPort4.Text     = LBConverter.ToInt32(dr["Port4"]).ToString();
                this.txtAccount4.Text  = dr["Account4"].ToString().TrimEnd();
                this.txtPassword4.Text = dr["Password4"].ToString().TrimEnd();

                this.cbUserCamera1.Checked = LBConverter.ToBoolean(dr["UseCamera1"]);
                this.cbUserCamera2.Checked = LBConverter.ToBoolean(dr["UseCamera2"]);
                this.cbUserCamera3.Checked = LBConverter.ToBoolean(dr["UseCamera3"]);
                this.cbUserCamera4.Checked = LBConverter.ToBoolean(dr["UseCamera4"]);
            }
        }
Beispiel #7
0
 public void UnCancel(FactoryArgs args, t_BigID ReceiveBillHeaderID)
 {
     using (DataTable dtHeader = _DALRPReceiveBillHeader.GetRPReceiveBillHeader(args, ReceiveBillHeaderID))
     {
         if (dtHeader.Rows.Count > 0)
         {
             DataRow drHeader     = dtHeader.Rows[0];
             bool    bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
             bool    bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
             if (bolIsApprove)
             {
                 throw new Exception("该充值单未审核,无法执行取消审核!");
             }
             if (!bolIsCancel)
             {
                 throw new Exception("该充值单已作废,无法执行取消审核!");
             }
         }
         else
         {
             throw new Exception("该充值单已删除,无法执行取消审核!");
         }
     }
     _DALRPReceiveBillHeader.UnCancel(args, ReceiveBillHeaderID);
 }
Beispiel #8
0
        /// <summary>
        /// 读取控件参数值
        /// </summary>
        private void ReadFieldValue()
        {
            if (mlBackUpConfigID > 0)
            {
                DataTable dtBackUp = ExecuteSQL.CallView(108, "", "BackUpConfigID=" + mlBackUpConfigID, "");
                if (dtBackUp.Rows.Count > 0)
                {
                    DataRow drBackUp          = dtBackUp.Rows[0];
                    int     iBackUpType       = LBConverter.ToInt32(drBackUp["BackUpType"]);
                    int     iBackUpWeek       = LBConverter.ToInt32(drBackUp["BackUpWeek"]);
                    int     iBackUpHour       = LBConverter.ToInt32(drBackUp["BackUpHour"]);
                    int     iBackUpMinu       = LBConverter.ToInt32(drBackUp["BackUpMinu"]);
                    bool    bolIsEffect       = LBConverter.ToBoolean(drBackUp["IsEffect"]);
                    int     iBackUpFileMaxNum = LBConverter.ToInt32(drBackUp["BackUpFileMaxNum"]);
                    string  strBackUpPath     = LBConverter.ToString(drBackUp["BackUpPath"]);
                    string  strBackUpName     = LBConverter.ToString(drBackUp["BackUpName"]);

                    this.txtBackUpFileMaxNum.Text    = iBackUpFileMaxNum.ToString();
                    this.txtBackUpHour.Text          = iBackUpHour.ToString();
                    this.txtBackUpMinu.Text          = iBackUpMinu.ToString();
                    this.txtBackUpWeek.SelectedValue = iBackUpWeek;
                    this.txtBackUpType.SelectedValue = iBackUpType;
                    this.txtBackUpName.Text          = strBackUpName;
                    this.chkIsEffect.Checked         = bolIsEffect;
                }
            }
        }
Beispiel #9
0
        private void ReadFieldValue()
        {
            if (mlReceiveBillHeaderID > 0)
            {
                DataTable dtHeader = ExecuteSQL.CallView(111, "", "ReceiveBillHeaderID=" + mlReceiveBillHeaderID, "");
                if (dtHeader.Rows.Count > 0)
                {
                    DataRow drHeader                    = dtHeader.Rows[0];
                    bool    bolIsApprove                = LBConverter.ToBoolean(drHeader["IsApprove"]);
                    bool    bolIsCancel                 = LBConverter.ToBoolean(drHeader["IsCancel"]);
                    decimal decReceiveAmount            = LBConverter.ToDecimal(drHeader["ReceiveAmount"]);
                    decimal decSalesReceiveAmountAdd    = LBConverter.ToDecimal(drHeader["SalesReceiveAmountAdd"]);
                    decimal decSalesReceiveAmountReduce = LBConverter.ToDecimal(drHeader["SalesReceiveAmountReduce"]);
                    decimal decOriginalAmount           = LBConverter.ToDecimal(drHeader["OriginalAmount"]);
                    this.txtBillDate.Text   = LBConverter.ToString(drHeader["BillDate"]);
                    this.txtBillStatus.Text = bolIsApprove?"已审核":
                                              (bolIsCancel?"已作废":("未审核"));
                    this.txtCustomerID.TextBox.SelectedItemID = drHeader["CustomerID"].ToString();
                    this.txtDescription.Text     = drHeader["Description"].ToString();
                    this.txtReceiveAmount.Text   = decReceiveAmount.ToString("N0");
                    this.txtReceiveBillCode.Text = drHeader["ReceiveBillCode"].ToString();

                    this.txtChangedBy.Text   = drHeader["ChangedBy"].ToString();
                    this.txtChangeTime.Text  = drHeader["ChangeTime"].ToString();
                    this.txtApproveBy.Text   = drHeader["ApproveBy"].ToString();
                    this.txtApproveTime.Text = drHeader["ApproveTime"].ToString();
                    this.txtCancelBy.Text    = drHeader["CancelBy"].ToString();
                    this.txtCancelTime.Text  = drHeader["CancelTime"].ToString();
                    this.txtRPReceiveType.TextBox.SelectedItemID = drHeader["ChargeTypeID"];
                    this.txtReceiveBankID.TextBox.SelectedItemID = drHeader["ReceiveBankID"];
                }
            }
        }
        public void Update(FactoryArgs args, t_BigID ModifyBillHeaderID, t_BigID CustomerID,
                           t_DTSmall BillDate, t_DTSmall EffectDate, t_String Description)
        {
            using (DataTable dtCustomer = _DALModifyBillHeader.GetCustomerByID(args, CustomerID))
            {
                if (dtCustomer.Rows.Count == 0)
                {
                    throw new Exception("所选客户不存在,保存不成功!");
                }
            }

            using (DataTable dtHeader = _DALModifyBillHeader.GetModifyBillHeader(args, ModifyBillHeaderID))
            {
                DataRow drHeader     = dtHeader.Rows[0];
                bool    bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
                bool    bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
                if (bolIsApprove)
                {
                    throw new Exception("该调价单已审核,无法保存修改!");
                }

                if (bolIsCancel)
                {
                    throw new Exception("该调价单已作废,无法保存修改!");
                }
            }

            _DALModifyBillHeader.Update(args, ModifyBillHeaderID, CustomerID, BillDate, EffectDate, Description);
        }
        private void ReadFeildValue()
        {
            string    strFilter = "SaleCarInBillID=" + mlSaleCarInBillID;
            DataTable dtBill    = ExecuteSQL.CallView(125, "", strFilter, "");

            if (dtBill.Rows.Count > 0)
            {
                DataRow drBill = dtBill.Rows[0];
                _drBillInfo                     = drBill;
                mlSaleCarOutBillID              = LBConverter.ToInt64(drBill["SaleCarOutBillID"]);
                this.lblBillDateIn.Text         = drBill["BillDateIn"].ToString().TrimEnd();
                this.lblBillDateOut.Text        = drBill["BillDateOut"].ToString().TrimEnd();
                this.txtSaleCarInBillCode.Text  = drBill["SaleCarInBillCode"].ToString().TrimEnd();
                this.txtSaleCarOutBillCode.Text = drBill["SaleCarOutBillCode"].ToString().TrimEnd();

                this.txtCalculateType.SelectedValue = drBill["CalculateType"];
                this.txtItemID.TextBox.Text         = drBill["ItemName"].ToString();
                this.txtCustomerID.TextBox.Text     = drBill["CustomerName"].ToString();
                this.txtCarID.TextBox.Text          = drBill["CarNum"].ToString();
                this.txtCarTare.Text              = drBill["CarTare"].ToString();
                this.txtDescription.Text          = drBill["Description"].ToString();
                this.txtReceiveType.SelectedValue = drBill["ReceiveType"];
                //this.txtSaleCarInBillID.Text = drv["SaleCarInBillID"].ToString().TrimEnd();
                //this.txtBillStatus.SelectedValue = drBill["BillStatus"];

                int iCalculateType = LBConverter.ToInt32(drBill["CalculateType"]);
                this.txtTotalWeight.Text  = drBill["TotalWeight"].ToString();
                this.txtCarTare.Text      = drBill["CarTare"].ToString();
                this.txtSuttleWeight.Text = drBill["SuttleWeight"].ToString();
                this.txtPrice.Text        = drBill["Price"].ToString();
                this.txtAmount.Text       = drBill["Amount"].ToString();
                this.lblPriceQty.Text     = iCalculateType == 0 ?
                                            drBill["SuttleWeight"].ToString() + "KG": "1 车";

                BillStatusStyle(
                    LBConverter.ToBoolean(drBill["IsCancel"]),
                    drBill["CancelBy"].ToString(),
                    drBill["CancelTime"].ToString(),
                    drBill["CancelDesc"].ToString(),
                    LBConverter.ToInt32(drBill["BillStatus"]));

                Thread thread = new Thread(ReadMonitoreImg);
                thread.Start();

                //读取退货单信息
                DataTable dtReturn = ExecuteSQL.CallView(137, "", strFilter, "");
                if (dtReturn.Rows.Count == 0)
                {
                    this.tabControl1.TabPages.Remove(this.tpReturnIn);
                    this.tabControl1.TabPages.Remove(this.tpReturnOut);
                }
                else
                {
                    long lSaleCarReturnBillID = LBConverter.ToInt64(dtReturn.Rows[0]["SaleCarReturnBillID"]);
                    thread = new Thread(ReadReturnImg);
                    thread.Start(lSaleCarReturnBillID);
                }
            }
        }
Beispiel #12
0
        private static void SetPrintSettings(FastReport.Report report, long lReportTemplateID)
        {
            DataTable dtReportTemplate = ExecuteSQL.CallView(105, "", "ReportTemplateID=" + lReportTemplateID, "");

            if (dtReportTemplate.Rows.Count > 0)
            {
                DataRow drReport = dtReportTemplate.Rows[0];

                string strPrinterName    = drReport["PrinterName"].ToString().TrimEnd();
                string strPaperType      = drReport["PaperType"].ToString().TrimEnd();
                int    PaperSizeHeight   = LBConverter.ToInt32(drReport["PaperSizeHeight"]);
                int    PaperSizeWidth    = LBConverter.ToInt32(drReport["PaperSizeWidth"]);
                bool   IsManualPaperType = LBConverter.ToBoolean(drReport["IsManualPaperType"]); //自动识别纸张类型
                bool   IsManualPaperSize = LBConverter.ToBoolean(drReport["IsManualPaperSize"]); //自动识别纸张大小
                bool   IsPaperTransverse = LBConverter.ToBoolean(drReport["IsPaperTransverse"]); //是否纵向打印

                if (strPrinterName != "")
                {
                    report.PrintSettings.Printer = strPrinterName;

                    /*if (IsManualPaperType)
                     * {
                     *  System.Drawing.Printing.PrinterSettings mSelectedPrinter = new System.Drawing.Printing.PrinterSettings();
                     *  int iIndex = 0;
                     *  foreach (System.Drawing.Printing.PaperSize pageSize in mSelectedPrinter.PaperSizes)
                     *  {
                     *      if (pageSize.PaperName.Equals(strPaperType))
                     *      {
                     *          //report.PrintSettings.PaperSource = Convert.ToInt32(pageSize.Kind);
                     *          break;
                     *      }
                     *      iIndex++;
                     *  }
                     *
                     *  report.PrintSettings.PaperSource = iIndex;
                     * }
                     *
                     * if (IsManualPaperSize)
                     * {
                     *  report.PrintSettings.PrintOnSheetHeight = PaperSizeHeight;
                     *  report.PrintSettings.PrintOnSheetWidth = PaperSizeWidth;
                     * }
                     *
                     * report.PrintSettings.Duplex = IsPaperTransverse ? System.Drawing.Printing.Duplex.Vertical :
                     *   System.Drawing.Printing.Duplex.Horizontal;
                     */
                }
            }
        }
Beispiel #13
0
        private void ReadFieldValue()
        {
            if (mlSupplierID > 0)
            {
                DataTable dtSupplier = ExecuteSQL.CallView(139, "", "SupplierID=" + mlSupplierID, "");
                if (dtSupplier.Rows.Count > 0)
                {
                    DataRow drSupplier = dtSupplier.Rows[0];

                    this.txtSupplierName.Text  = drSupplier["SupplierName"].ToString();
                    this.txtSupplierCode.Text  = drSupplier["SupplierCode"].ToString();
                    this.cbIsForbidden.Checked = LBConverter.ToBoolean(drSupplier["IsForbidden"]);
                }
            }
        }
Beispiel #14
0
        private void SetFieldValue()
        {
            DataTable dtDesc = ExecuteSQL.CallView(134, "", "MachineName='" + LoginInfo.MachineName + "'", "");

            if (dtDesc.Rows.Count > 0)
            {
                this.txtHeaderXType.SelectedValue = dtDesc.Rows[0]["HeaderXType"];
                this.txtTailXType.SelectedValue   = dtDesc.Rows[0]["TailXType"];
                this.txtHeaderYType.SelectedValue = dtDesc.Rows[0]["HeaderYType"];
                this.txtTailYType.SelectedValue   = dtDesc.Rows[0]["TailYType"];
                this.chkHeaderEffect.Checked      = LBConverter.ToBoolean(dtDesc.Rows[0]["IsHeaderEffect"]);
                this.chkTailEffect.Checked        = LBConverter.ToBoolean(dtDesc.Rows[0]["IsTailEffect"]);
                this.txtSerialName.SelectedValue  = dtDesc.Rows[0]["SerialName"].ToString().TrimEnd();
            }
        }
Beispiel #15
0
 public void UnForbid(FactoryArgs args, t_BigID CustomerID)
 {
     using (DataTable dtCustomer = _DALDbCustomer.GetCustomerByID(args, CustomerID))
     {
         if (dtCustomer.Rows.Count > 0)
         {
             bool bolIsForbid = LBConverter.ToBoolean(dtCustomer.Rows[0]["IsForbid"]);
             if (!bolIsForbid)
             {
                 throw new Exception("该客户未禁用,无法取消禁用!");
             }
         }
     }
     _DALDbCustomer.UnForbid(args, CustomerID);
 }
Beispiel #16
0
        private void ReadFieldValue()
        {
            if (mlCustomerID > 0)
            {
                DataTable dtHeader = ExecuteSQL.CallView(112, "", "CustomerID=" + mlCustomerID, "");
                if (dtHeader.Rows.Count > 0)
                {
                    DataRow drHeader = dtHeader.Rows[0];

                    this.txtK3CustomerCode.Text          = drHeader["K3CustomerCode"].ToString();
                    this.txtCustomerCode.Text            = drHeader["CustomerCode"].ToString();
                    this.txtCustomerName.Text            = drHeader["CustomerName"].ToString();
                    this.txtDescription.Text             = drHeader["Description"].ToString();
                    this.txtContact.Text                 = drHeader["Contact"].ToString();
                    this.txtPhone.Text                   = drHeader["Phone"].ToString();
                    this.txtAddress.Text                 = drHeader["Address"].ToString();
                    this.txtCreditAmount.Text            = drHeader["CreditAmount"].ToString();
                    this.txtAmountType.SelectedValue     = LBConverter.ToInt32(drHeader["AmountType"]);
                    this.txtReceiveType.SelectedValue    = LBConverter.ToInt32(drHeader["ReceiveType"]);
                    this.txtCustomerTypeID.SelectedValue = LBConverter.ToInt32(drHeader["CustomerTypeID"]);
                    this.txtAmountNotEnough.Text         = drHeader["AmountNotEnough"].ToString();

                    this.chkCarIsLimit.Checked      = LBConverter.ToBoolean(drHeader["CarIsLimit"]);
                    this.chkIsDisplayPrice.Checked  = LBConverter.ToBoolean(drHeader["IsDisplayPrice"]);
                    this.chkIsDisplayAmount.Checked = LBConverter.ToBoolean(drHeader["IsDisplayAmount"]);
                    this.chkIsPrintAmount.Checked   = LBConverter.ToBoolean(drHeader["IsPrintAmount"]);
                    this.chkIsAllowOverFul.Checked  = LBConverter.ToBoolean(drHeader["IsAllowOverFul"]);
                    this.chkIsAllowEmptyIn.Checked  = LBConverter.ToBoolean(drHeader["IsAllowEmptyIn"]);

                    this.txtCreateBy.Text   = drHeader["CreateBy"].ToString();
                    this.txtCreateTime.Text = drHeader["CreateTime"].ToString();
                    this.txtChangeBy.Text   = drHeader["ChangeBy"].ToString();
                    this.txtChangeTime.Text = drHeader["ChangeTime"].ToString();

                    decimal decSalesReceivedAmount = LBConverter.ToDecimal(drHeader["SalesReceivedAmount"]);
                    decimal decTotalReceivedAmount = LBConverter.ToDecimal(drHeader["TotalReceivedAmount"]);
                    decimal decOverRangeAmount     = decSalesReceivedAmount - decTotalReceivedAmount;
                    this.lblOverRangeAmount.Text = decOverRangeAmount > 0 ? decOverRangeAmount.ToString("0.00") : "0";
                    this.lblRemainAmount.Text    = decTotalReceivedAmount > decSalesReceivedAmount ? (decTotalReceivedAmount - decSalesReceivedAmount).ToString("0.00") : "0";

                    //是否禁用
                    bool bolIsForbid = LBConverter.ToBoolean(drHeader["IsForbid"]);
                    this.btnForbid.Visible   = !bolIsForbid;
                    this.btnUnForbid.Visible = bolIsForbid;
                    this.lblForbid.Visible   = bolIsForbid;
                }
            }
        }
        private List <DataRow> ReadSelectedRows()
        {
            this.grdMain.EndEdit();
            List <DataRow> lstSelected = new List <DataRow>();

            foreach (DataGridViewRow dgvr in this.grdMain.Rows)
            {
                bool bolLBSelect = LBConverter.ToBoolean(dgvr.Cells["LBSelect"].Value);
                if (bolLBSelect)
                {
                    DataRow dr = ((DataRowView)dgvr.DataBoundItem).Row;
                    lstSelected.Add(dr);
                }
            }
            return(lstSelected);
        }
Beispiel #18
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                this.grdMain.CurrentCell = null;
                this.grdMain.EndEdit();

                bool bolIsDeleted = false;
                if (LB.WinFunction.LBCommonHelper.ConfirmMessage("是否确认备份方案?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    foreach (DataGridViewRow dgvr in this.grdMain.Rows)
                    {
                        bool bolSelected = LBConverter.ToBoolean(dgvr.Cells["Selected"].Value);
                        if (bolSelected)
                        {
                            DataRowView drv             = dgvr.DataBoundItem as DataRowView;
                            long        lBackUpConfigID = LBConverter.ToInt64(drv["BackUpConfigID"]);
                            if (lBackUpConfigID > 0)
                            {
                                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                                parmCol.Add(new LBParameter("BackUpConfigID", enLBDbType.Int64, lBackUpConfigID));
                                DataSet dsReturn;
                                Dictionary <string, object> dictValue;
                                ExecuteSQL.CallSP(13202, parmCol, out dsReturn, out dictValue);
                                bolIsDeleted = true;
                            }
                        }
                    }
                    if (bolIsDeleted)
                    {
                        LB.WinFunction.LBCommonHelper.ShowCommonMessage("删除成功!");
                        LoadBackUpConfig();
                    }
                    else
                    {
                        LB.WinFunction.LBCommonHelper.ShowCommonMessage("请选择需要删除的数据行!");
                    }
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Beispiel #19
0
        public void UnApprove(FactoryArgs args, t_BigID ReceiveBillHeaderID)
        {
            t_Decimal ReceiveAmount            = new t_Decimal(0);
            t_BigID   CustomerID               = new t_BigID();
            t_Decimal SalesReceiveAmountAdd    = new t_Decimal(0);
            t_Decimal SalesReceiveAmountReduce = new t_Decimal(0);

            using (DataTable dtHeader = _DALRPReceiveBillHeader.GetRPReceiveBillHeader(args, ReceiveBillHeaderID))
            {
                if (dtHeader.Rows.Count > 0)
                {
                    DataRow drHeader     = dtHeader.Rows[0];
                    bool    bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
                    bool    bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
                    ReceiveAmount.SetValueWithObject(drHeader["ReceiveAmount"]);
                    SalesReceiveAmountAdd.SetValueWithObject(drHeader["SalesReceiveAmountAdd"]);
                    SalesReceiveAmountReduce.SetValueWithObject(drHeader["SalesReceiveAmountReduce"]);
                    CustomerID.SetValueWithObject(drHeader["CustomerID"]);
                    if (!bolIsApprove)
                    {
                        throw new Exception("该充值单未审核,无法执行取消审核!");
                    }
                    if (bolIsCancel)
                    {
                        throw new Exception("该充值单已作废,无法执行取消审核!");
                    }
                }
                else
                {
                    throw new Exception("该充值单已删除,无法执行取消审核!");
                }
            }
            DBHelper.ExecInTransDelegate exec = delegate(FactoryArgs argsInTrans)
            {
                _DALRPReceiveBillHeader.UnApprove(argsInTrans, ReceiveBillHeaderID);
                //扣减客户收款金额
                ReceiveAmount.SetValueWithObject(-ReceiveAmount.Value);
                SalesReceiveAmountAdd.SetValueWithObject(-SalesReceiveAmountAdd.Value);
                SalesReceiveAmountReduce.SetValueWithObject(-SalesReceiveAmountReduce.Value);
                _DALRPReceiveBillHeader.UpdateCustomerReceiveAmount(argsInTrans, CustomerID, ReceiveAmount, SalesReceiveAmountAdd, SalesReceiveAmountReduce);
            };
            DBHelper.ExecInTrans(args, exec);
        }
 private void grdMain_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
         {
             DataRowView drv         = this.grdMain.Rows[e.RowIndex].DataBoundItem as DataRowView;
             bool        bolIsForbid = LBConverter.ToBoolean(drv["IsForbid"]);
             if (bolIsForbid)
             {
                 e.CellStyle.ForeColor = Color.Red;
             }
         }
     }
     catch (Exception ex)
     {
         LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
     }
 }
        public void UnCancel(FactoryArgs args, t_BigID ModifyBillHeaderID)
        {
            using (DataTable dtHeader = _DALModifyBillHeader.GetModifyBillHeader(args, ModifyBillHeaderID))
            {
                DataRow drHeader     = dtHeader.Rows[0];
                bool    bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
                bool    bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
                if (bolIsApprove)
                {
                    throw new Exception("该调价单已审核,无法执行反作废操作!");
                }

                if (!bolIsCancel)
                {
                    throw new Exception("该调价单未作废,无法执行反作废操作!");
                }
            }

            _DALModifyBillHeader.UnCancel(args, ModifyBillHeaderID);
        }
Beispiel #22
0
        public void Update(FactoryArgs args, t_BigID ReceiveBillHeaderID, t_DTSmall BillDate, t_Decimal ReceiveAmount,
                           t_String Description, t_BigID ReceiveBankID, t_ID RPReceiveType, t_Decimal SalesReceiveAmountAdd,
                           t_Decimal SalesReceiveAmountReduce, t_Decimal OriginalAmount, t_BigID ChargeTypeID)
        {
            RPReceiveType.IsNullToZero();

            if (ReceiveAmount.Value == 0)
            {
                throw new Exception("充值金额不能为0!");
            }

            using (DataTable dtHeader = _DALRPReceiveBillHeader.GetRPReceiveBillHeader(args, ReceiveBillHeaderID))
            {
                if (dtHeader.Rows.Count > 0)
                {
                    DataRow drHeader     = dtHeader.Rows[0];
                    bool    bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
                    bool    bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
                    if (bolIsApprove)
                    {
                        throw new Exception("该充值单已审核,无法进行修改!");
                    }
                    if (bolIsCancel)
                    {
                        throw new Exception("该充值单已作废,无法进行修改!");
                    }
                }
                else
                {
                    throw new Exception("该充值单已删除,无法进行修改!");
                }
            }
            _DALRPReceiveBillHeader.Update(args, ReceiveBillHeaderID, BillDate, ReceiveAmount,
                                           Description, ReceiveBankID, RPReceiveType, SalesReceiveAmountAdd, SalesReceiveAmountReduce, OriginalAmount,
                                           ChargeTypeID);
        }
        private void SynToServer()
        {
            try
            {
                #region -- 将客户资料下载到本地 --

                foreach (KeyValuePair <int, DataRow> keyvalue in _dictDownLoadToClient)
                {
                    DataRow   drCustomer = keyvalue.Value;
                    DataTable dtCustomer = drCustomer.Table.Clone();
                    dtCustomer.ImportRow(drCustomer);
                    bool bolIsAdd = LBConverter.ToBoolean(drCustomer["IsAdd"]);//是否添加
                    try
                    {
                        if (bolIsAdd)
                        {
                            //添加
                            DataSet   dsReturn;
                            DataTable dtOut;
                            if (dtCustomer != null)
                            {
                                ExecuteSQL.CallSP(13403, dtCustomer, out dsReturn, out dtOut);
                                long lCustomerID_Out = 0;
                                if (dtOut != null && dtOut.Rows.Count > 0)
                                {
                                    foreach (DataColumn dc in dtOut.Columns)
                                    {
                                        if (dc.ColumnName.Contains("CustomerID"))
                                        {
                                            lCustomerID_Out = LBConverter.ToInt64(dtOut.Rows[0]["CustomerID"]);
                                            break;
                                        }
                                    }
                                }
                                if (lCustomerID_Out > 0)
                                {
                                    this._dictDownLoadMsg.Add(keyvalue.Key, "成功");
                                }
                            }
                        }
                        else
                        {
                            //编辑
                            if (dtCustomer != null)
                            {
                                DataSet   dsReturn;
                                DataTable dtOut;
                                ExecuteSQL.CallSP(13404, dtCustomer, out dsReturn, out dtOut);
                                _dictDownLoadMsg.Add(keyvalue.Key, "成功");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        _dictDownLoadMsg.Add(keyvalue.Key, ex.Message);
                    }
                }

                #endregion -- 将客户资料下载到本地 --
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #24
0
        private void btnExportXML_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder strSaleCarInBillID = new StringBuilder();
                DataView      dvSource           = this.grdMain.DataSource as DataView;
                foreach (DataRowView drv in dvSource)
                {
                    long lSaleCarInBillID  = LBConverter.ToInt64(drv["SaleCarInBillID"]);
                    long lSaleCarOutBillID = LBConverter.ToInt64(drv["SaleCarOutBillID"]);
                    bool IsCancel          = LBConverter.ToBoolean(drv["IsCancel"]);

                    if ((lSaleCarInBillID > 0 && lSaleCarOutBillID > 0) ||
                        (lSaleCarInBillID > 0 && IsCancel))
                    {
                        if (strSaleCarInBillID.ToString() != "")
                        {
                            strSaleCarInBillID.Append(",");
                        }
                        strSaleCarInBillID.Append(lSaleCarInBillID.ToString());
                    }
                }

                if (strSaleCarInBillID.ToString() != "")
                {
                    DataSet dsBill = new DataSet("Bill");
                    //查询入场单
                    DataTable dtInBill = ExecuteSQL.CallView(128, "", "SaleCarInBillID in (" + strSaleCarInBillID.ToString() + ")", "SaleCarInBillID asc");
                    dtInBill.TableName = "InBill";
                    //查询出场单
                    DataTable dtOutBill = ExecuteSQL.CallView(124, "", "SaleCarInBillID in (" + strSaleCarInBillID.ToString() + ")", "SaleCarInBillID asc");
                    dtOutBill.TableName = "OutBill";
                    //客户资料
                    DataTable dtCustomer = ExecuteSQL.CallView(110, "", "", "");
                    dtCustomer.TableName = "Customer";
                    //车牌号码
                    DataTable dtCar = ExecuteSQL.CallView(113, "", "", "");
                    dtCar.TableName = "Car";

                    dsBill.Tables.Add(dtInBill);
                    dsBill.Tables.Add(dtOutBill);
                    dsBill.Tables.Add(dtCustomer);
                    dsBill.Tables.Add(dtCar);

                    string localFilePath = "";
                    //string localFilePath, fileNameExt, newFileName, FilePath;
                    SaveFileDialog sfd = new SaveFileDialog();
                    //设置文件类型
                    sfd.Filter = "BAK文件(*.bak)|*.bak";

                    //设置默认文件类型显示顺序
                    sfd.FilterIndex = 1;

                    //保存对话框是否记忆上次打开的目录
                    sfd.RestoreDirectory = true;

                    //点了保存按钮进入
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        localFilePath = sfd.FileName.ToString(); //获得文件路径
                        dsBill.WriteXml(localFilePath);
                        LB.WinFunction.LBCommonHelper.ShowCommonMessage("导出成功!");
                    }
                    //dsBill.WriteXml()
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Beispiel #25
0
        //选择车辆触发事件
        private void CarTextBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                mlSaleCarInBillID = 0;
                string strCarNum   = this.txtCarID.TextBox.Text.ToString();
                long   lCarID      = 0;
                long   lCustomerID = 0;
                #region -- 读取车辆ID号 --
                using (DataTable dtCar = ExecuteSQL.CallView(117, "CarID,CustomerID", "CarNum='" + strCarNum + "'", ""))
                {
                    if (dtCar.Rows.Count > 0)
                    {
                        lCarID      = LBConverter.ToInt64(dtCar.Rows[0]["CarID"]);
                        lCustomerID = LBConverter.ToInt64(dtCar.Rows[0]["CustomerID"]);
                    }
                }
                #endregion -- 读取车辆ID号 --

                if (lCarID > 0)//如果存在该车辆
                {
                    #region --  判断该车辆是否已入场 --

                    bool bolExists = false;
                    LBDbParameterCollection parmCol = new LBDbParameterCollection();
                    parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));

                    DataSet dsReturn;
                    Dictionary <string, object> dictValue;
                    ExecuteSQL.CallSP(14101, parmCol, out dsReturn, out dictValue);
                    if (dictValue != null && dictValue.Keys.Count > 0)
                    {
                        if (dictValue.ContainsKey("IsReaded"))
                        {
                            bolExists = LBConverter.ToBoolean(dictValue["IsReaded"]);
                        }

                        if (bolExists)                     //已读取入场记录
                        {
                            this.txtTotalWeight.Text = ""; //清空毛重
                            this.txtPrice.Text       = ""; //清空单价

                            #region -- 读取入场记录,并将入场记录值填写到对应控件 --

                            if (dictValue.ContainsKey("CalculateType"))
                            {
                                this.txtCalculateType.SelectedValue = LBConverter.ToInt32(dictValue["CalculateType"]);
                            }
                            if (dictValue.ContainsKey("ItemID"))
                            {
                                this.txtItemID.TextBox.SelectedItemID = LBConverter.ToInt64(dictValue["ItemID"]);
                            }
                            if (dictValue.ContainsKey("CustomerID"))
                            {
                                this.txtCustomerID.TextBox.SelectedItemID = LBConverter.ToInt64(dictValue["CustomerID"]);
                            }
                            if (dictValue.ContainsKey("CarTare"))
                            {
                                this.txtCarTare.Text = LBConverter.ToString(dictValue["CarTare"]);
                            }
                            if (dictValue.ContainsKey("ReceiveType"))
                            {
                                this.txtReceiveType.SelectedValue = LBConverter.ToInt32(dictValue["ReceiveType"]);
                            }
                            if (dictValue.ContainsKey("SaleCarInBillID"))
                            {
                                mlSaleCarInBillID = LBConverter.ToInt64(dictValue["SaleCarInBillID"]);
                            }
                            //读取物料价格
                            ReadPrice();

                            #endregion -- 读取入场记录,并将入场记录值填写到对应控件 --
                        }
                        else
                        {
                            #region -- 该车无入场记录 --
                            this.txtCustomerID.TextBox.Text = "";
                            this.txtItemID.TextBox.Text     = "";
                            this.txtTotalWeight.Text        = "";
                            this.txtPrice.Text = "";
                            #endregion -- 该车无入场记录 --
                        }
                    }

                    #endregion
                }
                else
                {
                    this.txtCustomerID.TextBox.Text = "";
                    this.txtItemID.TextBox.Text     = "";
                    this.txtTotalWeight.Text        = "";
                    this.txtPrice.Text = "";
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
        private void SynBaseInfo()
        {
            try
            {
                #region -- 同步客户信息 --

                DataTable dtAddCustomer;
                DataTable dtEditCustomer;
                SynchronousCustomer.CompareClientAndServer(out dtAddCustomer, out dtEditCustomer);
                dtAddCustomer.Columns.Add("IsAdd", typeof(int));
                dtEditCustomer.Columns.Add("IsAdd", typeof(int));

                foreach (DataRow dr in dtAddCustomer.Rows)
                {
                    dr["IsAdd"] = 1;
                }

                DataTable dtCustomer = dtAddCustomer.Clone();
                dtCustomer.Merge(dtAddCustomer);
                dtCustomer.Merge(dtEditCustomer);

                foreach (DataRow drCustomer in dtCustomer.Rows)
                {
                    if (bolIsKillThread)
                    {
                        break;
                    }
                    string    strCustomerName = drCustomer["CustomerName"].ToString().Trim();
                    DataTable dtCustomerSP    = drCustomer.Table.Clone();
                    dtCustomerSP.ImportRow(drCustomer);
                    bool bolIsAdd = LBConverter.ToBoolean(drCustomer["IsAdd"]);//是否添加
                    try
                    {
                        if (bolIsAdd)
                        {
                            //添加
                            DataSet   dsReturn;
                            DataTable dtOut;
                            if (dtCustomerSP != null)
                            {
                                ExecuteSQL.CallSP(13403, dtCustomerSP, out dsReturn, out dtOut);
                                long lCustomerID_Out = 0;
                                if (dtOut != null && dtOut.Rows.Count > 0)
                                {
                                    foreach (DataColumn dc in dtOut.Columns)
                                    {
                                        if (dc.ColumnName.Contains("CustomerID"))
                                        {
                                            lCustomerID_Out = LBConverter.ToInt64(dtOut.Rows[0]["CustomerID"]);
                                            break;
                                        }
                                    }
                                }
                                if (lCustomerID_Out > 0)
                                {
                                    InsertCustomerListView(strCustomerName, "添加成功");
                                }
                            }
                        }
                        else
                        {
                            //编辑
                            if (dtCustomerSP != null)
                            {
                                DataSet   dsReturn;
                                DataTable dtOut;
                                ExecuteSQL.CallSP(13404, dtCustomerSP, out dsReturn, out dtOut);
                                InsertCustomerListView(strCustomerName, "修改成功");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        InsertCustomerListView(strCustomerName, "失败:" + ex.Message);
                    }
                }

                #endregion

                #region --同步车辆信息 --

                DataTable dtAddCar;
                DataTable dtEditCar;
                SynchronousCar.CompareClientAndServer(out dtAddCar, out dtEditCar);
                dtAddCar.Columns.Add("IsAdd", typeof(int));
                dtEditCar.Columns.Add("IsAdd", typeof(int));

                foreach (DataRow dr in dtAddCar.Rows)
                {
                    dr["IsAdd"] = 1;
                }

                DataTable dtCarDownLoad = dtAddCar.Clone();
                dtCarDownLoad.Merge(dtAddCar);
                dtCarDownLoad.Merge(dtEditCar);

                DataTable dtCarUpload;
                SynchronousCar.CompareClientDiffServer(out dtCarUpload);
                if (bolIsKillThread)
                {
                    return;
                }

                #region -- 同步至服务器 --
                foreach (DataRow drCar in dtCarUpload.Rows)
                {
                    if (bolIsKillThread)
                    {
                        break;
                    }
                    string    strCarNum       = drCar["CarNum"].ToString().TrimEnd();
                    string    strCustomerName = drCar["CustomerName"].ToString().TrimEnd();
                    DataTable dtCustomer1     = ExecuteSQL.CallView_Service(110, "CustomerID", "CustomerName='" + strCustomerName + "'", "");
                    if (dtCustomer1.Rows.Count > 0)
                    {
                        drCar["CustomerID"] = dtCustomer1.Rows[0]["CustomerID"];
                    }
                    else
                    {
                        drCar["CustomerID"] = DBNull.Value;
                    }

                    DataTable dtCar = drCar.Table.Clone();
                    dtCar.ImportRow(drCar);

                    try
                    {
                        DataSet   dsResult;
                        DataTable dtResult;
                        SynchronousCar.AddServerCarData(dtCar, out dsResult, out dtResult);
                        long lCarID = 0;
                        if (dtResult != null && dtResult.Rows.Count > 0)
                        {
                            foreach (DataColumn dc in dtResult.Columns)
                            {
                                if (dc.ColumnName.Contains("CarID"))
                                {
                                    lCarID = LBConverter.ToInt64(dtResult.Rows[0]["CarID"]);
                                    break;
                                }
                            }
                        }
                        if (lCarID > 0)
                        {
                            InsertCarListView(strCarNum, "成功同步至服务器");
                        }
                    }
                    catch (Exception ex)
                    {
                        InsertCarListView(strCarNum, "失败:" + ex.Message);
                    }
                }
                #endregion -- 同步至服务器 --

                if (bolIsKillThread)
                {
                    return;
                }

                #region -- 将客户资料下载到本地 --

                foreach (DataRow drCar in dtCarDownLoad.Rows)
                {
                    if (bolIsKillThread)
                    {
                        break;
                    }
                    string    strCarNum       = drCar["CarNum"].ToString().TrimEnd();
                    string    strCustomerName = drCar["CustomerName"].ToString().TrimEnd();
                    DataTable dtCustomer1     = ExecuteSQL.CallView(110, "CustomerID", "CustomerName='" + strCustomerName + "'", "");
                    if (dtCustomer1.Rows.Count > 0)
                    {
                        drCar["CustomerID"] = dtCustomer1.Rows[0]["CustomerID"];
                    }
                    else
                    {
                        drCar["CustomerID"] = DBNull.Value;
                    }

                    DataTable dtCarTemp = drCar.Table.Clone();
                    dtCarTemp.ImportRow(drCar);

                    bool bolIsAdd = LBConverter.ToBoolean(drCar["IsAdd"]);//是否添加
                    try
                    {
                        if (bolIsAdd)
                        {
                            //添加
                            DataSet   dsReturn;
                            DataTable dtOut;
                            if (dtCarTemp != null)
                            {
                                ExecuteSQL.CallSP(13500, dtCarTemp, out dsReturn, out dtOut);
                                long lCarID_Out = 0;
                                if (dtOut != null && dtOut.Rows.Count > 0)
                                {
                                    foreach (DataColumn dc in dtOut.Columns)
                                    {
                                        if (dc.ColumnName.Contains("CarID"))
                                        {
                                            lCarID_Out = LBConverter.ToInt64(dtOut.Rows[0]["CarID"]);
                                            break;
                                        }
                                    }
                                }
                                if (lCarID_Out > 0)
                                {
                                    InsertCarListView(strCarNum, "成功同步至本地");
                                }
                            }
                        }
                        else
                        {
                            //编辑
                            if (dtCarTemp != null)
                            {
                                DataSet   dsReturn;
                                DataTable dtOut;
                                ExecuteSQL.CallSP(13501, dtCarTemp, out dsReturn, out dtOut);
                                InsertCarListView(strCarNum, "成功同步至本地");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        InsertCarListView(strCarNum, "失败:" + ex.Message);
                    }
                }

                #endregion -- 将客户资料下载到本地 --

                if (bolIsKillThread)
                {
                    return;
                }
                #endregion --同步车辆信息 --

                try
                {
                    SynchronousPrice.SynchronousClientFromServer();//价格表同步
                }
                catch (Exception ex)
                {
                    InsertPriceListView("同步失败:" + ex.Message);
                }

                bolIsFinished = true;
            }
            catch (Exception ex)
            {
                strMsg = ex.Message;
            }
        }
Beispiel #27
0
        public static void SynchronousBillToServer(DataTable dtBill)
        {
            foreach (DataRow dr in dtBill.Rows)
            {
                long lCustomerID = 0;
                long lCarID      = 0;
                long lItemID     = 0;
                long lItemTypeID = 0;

                //客户名称
                string strCustomerName = dr["CustomerName"].ToString().TrimEnd();
                //车辆名称
                string strCarName = dr["CarNum"].ToString().TrimEnd();
                //物料名称
                string strItemName = dr["ItemName"].ToString().TrimEnd();
                //物料分类
                string strItemTypeName = dr["ItemTypeName"].ToString().TrimEnd();
                //入场单号
                string strSaleCarInBillCode = dr["SaleCarInBillCode"].ToString().TrimEnd();
                long   lSaleCarInBillID     = LBConverter.ToInt32(dr["SaleCarInBillID"]);

                //判断服务器是否存在该客户
                DataTable dtCustomerServer = ExecuteSQL.CallView_Service(112, "CustomerID", "CustomerName='" + strCustomerName + "'", "");
                if (dtCustomerServer.Rows.Count == 0)//服务器不存在该客户
                {
                    DataSet   dsOut;
                    DataTable dtOut;
                    DataTable dtCustomerClient = ExecuteSQL.CallView(112, "", "CustomerID=" + dr["CustomerID"].ToString(), "");
                    SynchronousCustomer.AddServerCustomerData(dtCustomerClient, out dsOut, out dtOut);//向服务器添加新客户
                    if (dtOut != null && dtOut.Rows.Count > 0)
                    {
                        foreach (DataColumn dc in dtOut.Columns)
                        {
                            if (dc.ColumnName.Contains("CustomerID"))
                            {
                                lCustomerID = LBConverter.ToInt64(dtOut.Rows[0]["CustomerID"]);
                            }
                        }
                    }
                }
                else
                {
                    lCustomerID = LBConverter.ToInt64(dtCustomerServer.Rows[0]["CustomerID"]);
                }
                //判断服务器是否存在该车辆
                DataTable dtCarServer = ExecuteSQL.CallView_Service(117, "CarID", "CarNum='" + strCarName + "'", "");
                if (dtCarServer.Rows.Count == 0)//服务器不存在该车辆
                {
                    DataSet   dsOut;
                    DataTable dtOut;
                    DataTable dtCarClient = ExecuteSQL.CallView(117, "", "CarID=" + dr["CarID"].ToString(), "");
                    SynchronousCar.AddServerCarData(dtCarClient, out dsOut, out dtOut);//添加新客户
                    if (dtOut != null && dtOut.Rows.Count > 0)
                    {
                        foreach (DataColumn dc in dtOut.Columns)
                        {
                            if (dc.ColumnName.Contains("CarID"))
                            {
                                lCarID = LBConverter.ToInt64(dtOut.Rows[0]["CarID"]);
                            }
                        }
                    }
                }
                else
                {
                    lCarID = LBConverter.ToInt64(dtCarServer.Rows[0]["CarID"]);
                }

                //判断服务器是否存在该物料类别
                DataTable dtItemTypeServer = ExecuteSQL.CallDirectSQL_Service("select * from dbo.DbItemType where ItemTypeName='" + strItemTypeName + "'");
                if (dtItemTypeServer.Rows.Count == 0)//服务器不存在该物料类别
                {
                    DataSet   dsOut;
                    DataTable dtOut;
                    DataTable dtItemTypeClient = ExecuteSQL.CallDirectSQL("select * from dbo.DbItemType where ItemTypeName='" + strItemTypeName + "'");
                    SynchronousItem.AddServerItemTypeData(dtItemTypeClient, out dsOut, out dtOut);//添加新物料
                    if (dtOut != null && dtOut.Rows.Count > 0)
                    {
                        foreach (DataColumn dc in dtOut.Columns)
                        {
                            if (dc.ColumnName.Contains("ItemTypeID"))
                            {
                                lItemTypeID = LBConverter.ToInt64(dtOut.Rows[0]["ItemTypeID"]);
                            }
                        }
                    }
                }
                else
                {
                    lItemTypeID = LBConverter.ToInt64(dtItemTypeServer.Rows[0]["ItemTypeID"]);
                }

                //判断服务器是否存在该物料
                DataTable dtItemServer = ExecuteSQL.CallView_Service(203, "ItemID", "ItemName='" + strItemName + "'", "");
                if (dtItemServer.Rows.Count == 0)//服务器不存在该物料
                {
                    DataSet   dsOut;
                    DataTable dtOut;
                    DataTable dtItemClient = ExecuteSQL.CallView(203, "", "ItemID=" + dr["ItemID"].ToString(), "");
                    dtItemClient.Rows[0]["ItemTypeID"] = lItemTypeID;
                    SynchronousItem.AddServerItemData(dtItemClient, out dsOut, out dtOut);//添加新物料
                    if (dtOut != null && dtOut.Rows.Count > 0)
                    {
                        foreach (DataColumn dc in dtOut.Columns)
                        {
                            if (dc.ColumnName.Contains("ItemID"))
                            {
                                lItemID = LBConverter.ToInt64(dtOut.Rows[0]["ItemID"]);
                            }
                        }
                    }
                }
                else
                {
                    lItemID = LBConverter.ToInt64(dtItemServer.Rows[0]["ItemID"]);
                }

                if (lCustomerID > 0 && lCarID > 0 && lItemID > 0)
                {
                    dr["CustomerID"] = lCustomerID;
                    dr["CarID"]      = lCarID;
                    dr["ItemID"]     = lItemID;
                    DataTable dtData = dtBill.Clone();
                    dtData.ImportRow(dr);
                    //同步订单
                    DataSet   dsReturn;
                    DataTable dtOut;

                    DataTable dtSP = new DataTable("SPIN");
                    dtSP.Columns.Add("DTInOutBill", typeof(DataTable));
                    dtSP.Columns.Add("IsSynchronousBefore", typeof(bool));
                    dtSP.Rows.Add(dtData);
                    dtSP.AcceptChanges();
                    ExecuteSQL.CallSP_Service(14122, dtSP, out dsReturn, out dtOut);
                    bool bolIsSynchronousBefore = false;
                    if (dtOut != null && dtOut.Rows.Count > 0)
                    {
                        foreach (DataColumn dc in dtOut.Columns)
                        {
                            if (dc.ColumnName.Contains("IsSynchronousBefore"))
                            {
                                bolIsSynchronousBefore = LBConverter.ToBoolean(dtOut.Rows[0]["IsSynchronousBefore"]);
                                break;
                            }
                        }
                    }

                    //同步成功后将当前单据的同步状态改为已同步
                    dtSP = new DataTable("SPIN");
                    dtSP.Columns.Add("SaleCarInBillID", typeof(long));
                    dtSP.Rows.Add(lSaleCarInBillID);
                    dtSP.AcceptChanges();
                    ExecuteSQL.CallSP(14123, dtSP, out dsReturn, out dtOut);

                    if (bolIsSynchronousBefore)
                    {
                        throw new Exception("[" + strSaleCarInBillCode + "]已同步过!");
                    }

                    Application.DoEvents();
                }
                else
                {
                    string strMsg = "";
                    if (lCustomerID == 0)
                    {
                        strMsg += "[客户资料]";
                    }
                    if (lCarID == 0)
                    {
                        strMsg += "[车辆资料]";
                    }
                    if (lItemID == 0)
                    {
                        strMsg += "[物料资料]";
                    }
                    throw new Exception("入场订单[" + strSaleCarInBillCode + "]同步失败!无法同步" + strMsg);
                }
            }
        }
Beispiel #28
0
        private void SetButtonStatus()
        {
            this.txtBillDate.Enabled       = true;
            this.txtCustomerID.Enabled     = true;
            this.txtDescription.ReadOnly   = false;
            this.txtReceiveAmount.ReadOnly = false;

            this.btnSave.Visible      = true;
            this.btnDelete.Visible    = true;
            this.btnCancel.Visible    = true;
            this.btnUnCancel.Visible  = true;
            this.btnApprove.Visible   = true;
            this.btnUnApprove.Visible = true;
            this.btnAdd.Visible       = true;

            if (mlReceiveBillHeaderID > 0)
            {
                DataTable dtReceiveBill = ExecuteSQL.CallView(109, "", "ReceiveBillHeaderID=" + mlReceiveBillHeaderID, "");
                if (dtReceiveBill.Rows.Count > 0)
                {
                    DataRow drBill = dtReceiveBill.Rows[0];
                    this.txtChangedBy.Text   = drBill["ChangedBy"].ToString();
                    this.txtChangeTime.Text  = drBill["ChangeTime"].ToString();
                    this.txtApproveBy.Text   = drBill["ApproveBy"].ToString();
                    this.txtApproveTime.Text = drBill["ApproveTime"].ToString();
                    this.txtCancelBy.Text    = drBill["CancelBy"].ToString();
                    this.txtCancelTime.Text  = drBill["CancelTime"].ToString();
                    bool bolIsApprove = LBConverter.ToBoolean(drBill["IsApprove"]);
                    bool bolIsCancel  = LBConverter.ToBoolean(drBill["IsCancel"]);
                    if (bolIsApprove)
                    {
                        this.lblBillStatus.Visible = true;
                        this.lblBillStatus.Text    = "(审核)";
                        this.txtBillStatus.Text    = "已审核";

                        this.btnSave.Visible     = false;
                        this.btnDelete.Visible   = false;
                        this.btnCancel.Visible   = false;
                        this.btnUnCancel.Visible = false;
                        this.btnApprove.Visible  = false;

                        this.txtBillDate.Enabled       = false;
                        this.txtCustomerID.Enabled     = false;
                        this.txtDescription.ReadOnly   = true;
                        this.txtReceiveAmount.ReadOnly = true;
                        this.btnAdd.Visible            = true;
                    }
                    else if (bolIsCancel)
                    {
                        this.lblBillStatus.Visible = true;
                        this.lblBillStatus.Text    = "(作废)";
                        this.txtBillStatus.Text    = "已作废";

                        this.btnSave.Visible      = false;
                        this.btnDelete.Visible    = false;
                        this.btnCancel.Visible    = false;
                        this.btnApprove.Visible   = false;
                        this.btnUnApprove.Visible = false;

                        this.txtBillDate.Enabled       = false;
                        this.txtCustomerID.Enabled     = false;
                        this.txtDescription.ReadOnly   = true;
                        this.txtReceiveAmount.ReadOnly = true;
                        this.btnAdd.Visible            = true;
                    }
                    else
                    {
                        this.lblBillStatus.Visible = false;
                        this.txtBillStatus.Text    = "未审核";

                        this.btnUnCancel.Visible  = false;
                        this.btnUnApprove.Visible = false;
                        this.btnAdd.Visible       = true;
                    }
                }
                else
                {
                    mlReceiveBillHeaderID = 0;

                    this.lblBillStatus.Visible = false;
                    this.txtBillStatus.Text    = "添加";

                    this.btnDelete.Visible    = false;
                    this.btnCancel.Visible    = false;
                    this.btnUnCancel.Visible  = false;
                    this.btnApprove.Visible   = false;
                    this.btnUnApprove.Visible = false;
                    this.btnAdd.Visible       = true;

                    ClearFieldValue();
                }
            }
            else
            {
                this.lblBillStatus.Visible = false;
                this.txtBillStatus.Text    = "添加";

                this.btnDelete.Visible    = false;
                this.btnCancel.Visible    = false;
                this.btnUnCancel.Visible  = false;
                this.btnApprove.Visible   = false;
                this.btnUnApprove.Visible = false;
                this.btnAdd.Visible       = false;

                ClearFieldValue();
            }
        }
Beispiel #29
0
        private void SynK3()
        {
            foreach (DataRow dr in mlstRows)
            {
                bool   bolIsSuccess          = false;
                string strSynError           = "";
                string strSaleCarOutBillCode = dr["SaleCarOutBillCode"].ToString().TrimEnd();
                try
                {
                    long lSaleCarInBillID           = LBConverter.ToInt64(dr["SaleCarInBillID"]);
                    LBDbParameterCollection parmCol = new LBDbParameterCollection();
                    parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, lSaleCarInBillID));
                    parmCol.Add(new LBParameter("SynType", enLBDbType.Int64, _SynType));
                    parmCol.Add(new LBParameter("IsReSynBill", enLBDbType.Boolean, mbolIsReSynBill?1:0));

                    DataSet dsReturn;
                    Dictionary <string, object> dictValue;
                    ExecuteSQL.CallSP(14124, parmCol, out dsReturn, out dictValue);
                    strMsg = "已同步磅单:" + strSaleCarOutBillCode;
                    //LogHelper.WriteLog("准备同步:" + strSaleCarOutBillCode);
                    bool   bolOutBillIsSuccess = false;
                    bool   bolReceiveIsSuccess = false;
                    string strOutBillSynError  = "";
                    string strReceiveSynError  = "";

                    if (dictValue.ContainsKey("OutBillIsSuccess"))
                    {
                        bolOutBillIsSuccess = LBConverter.ToBoolean(dictValue["OutBillIsSuccess"]);
                    }
                    if (dictValue.ContainsKey("ReceiveIsSuccess"))
                    {
                        bolReceiveIsSuccess = LBConverter.ToBoolean(dictValue["ReceiveIsSuccess"]);
                    }
                    if (dictValue.ContainsKey("OutBillSynError"))
                    {
                        strOutBillSynError = dictValue["OutBillSynError"].ToString().TrimEnd();
                    }
                    if (dictValue.ContainsKey("ReceiveSynError"))
                    {
                        strReceiveSynError = dictValue["ReceiveSynError"].ToString().TrimEnd();
                    }


                    if (_SynType == 0)//应收
                    {
                        bolIsSuccess = bolReceiveIsSuccess;
                        strSynError  = strReceiveSynError;
                    }
                    else if (_SynType == 1)//出库
                    {
                        bolIsSuccess = bolOutBillIsSuccess;
                        strSynError  = strOutBillSynError;
                    }
                    //LogHelper.WriteLog("同步结果:" + strSynError);
                }
                catch (Exception ex)
                {
                    strSynError = "磅单同步错误:" + strSaleCarOutBillCode + " 原因:" + ex.Message;

                    //LogHelper.WriteLog("报错:" + strSynError);
                }
                finally
                {
                    if (this.listView1.InvokeRequired)
                    {
                        this.listView1.Invoke((MethodInvoker) delegate {
                            ListViewItem item = new ListViewItem(strSaleCarOutBillCode);
                            if (bolIsSuccess)
                            {
                                strSynError = strSynError != "" ? strSynError : "同步成功";
                                _SuccessCount++;
                            }
                            else
                            {
                                strSynError = "同步失败:" + strSynError;
                                _FailCount++;
                            }
                            item.SubItems.Add(strSynError);
                            this.listView1.Items.Add(item);
                        });
                    }

                    TotalSynRows++;
                }
            }
        }
        public void UnApprove(FactoryArgs args, t_BigID ModifyBillHeaderID)
        {
            t_BigID CustomerID = new t_BigID();

            using (DataTable dtHeader = _DALModifyBillHeader.GetModifyBillHeader(args, ModifyBillHeaderID))
            {
                DataRow drHeader = dtHeader.Rows[0];
                CustomerID.SetValueWithObject(drHeader["CustomerID"]);
                bool bolIsApprove = LBConverter.ToBoolean(drHeader["IsApprove"]);
                bool bolIsCancel  = LBConverter.ToBoolean(drHeader["IsCancel"]);
                if (!bolIsApprove)
                {
                    throw new Exception("该调价单未审核,无法执行反审核操作!");
                }

                if (bolIsCancel)
                {
                    throw new Exception("该调价单已作废,无法执行反审核操作!");
                }
            }
            _DALModifyBillHeader.UnApprove(args, ModifyBillHeaderID);

            /*DBHelper.ExecInTransDelegate exec = delegate (FactoryArgs argsInTrans)
             * {
             #region -- 取消审核订单时,更新或删除物料价格表 --
             *
             *  using (DataTable dtDetail = _DALModifyBillDetail.GetModifyBillDetailByHeaderID(argsInTrans, ModifyBillHeaderID))
             *  {
             *      foreach (DataRow drDetail in dtDetail.Rows)
             *      {
             *          t_BigID ItemID = new t_BigID(drDetail["ItemID"]);
             *          t_BigID CarID = new t_BigID(drDetail["CarID"]);
             *          t_ID CalculateType = new t_ID(drDetail["CalculateType"]);
             *          t_Decimal Price = new t_Decimal(drDetail["Price"]);
             *          t_BigID ModifyBillDetailID = new t_BigID(drDetail["ModifyBillDetailID"]);
             *
             *          t_BigID ItemPriceID = new t_BigID();//价格表记录
             *          using (DataTable dtPrice = _DALModifyBillHeader.GetSMItemPrice(argsInTrans,
             *              CustomerID, CarID, ItemID, CalculateType))
             *          {
             *              if (dtPrice.Rows.Count > 0)
             *              {
             #region --如果已存在记录,则更新单价 --
             *
             *                  DataRow drPrice = dtPrice.Rows[0];
             *                  ItemPriceID.SetValueWithObject(drDetail["Price"]);
             *
             #endregion --如果已存在记录,则更新单价 --
             *              }
             *          }
             *
             *          //查询除了本记录之外,最新审核的调价明细行
             *          using (DataTable dtLastDetail = _DALModifyBillDetail.GetLastModifyBillDetail(argsInTrans,
             *                      ModifyBillDetailID, CustomerID, CarID, ItemID, CalculateType))
             *          {
             *              if (dtLastDetail.Rows.Count > 0)
             *              {
             #region --如果已存在记录,则更新单价 --
             *                  DataRow drPrice = dtLastDetail.Rows[0];
             *                  //t_BigID LastModifyBillDetailID = new t_BigID(drPrice["ModifyBillDetailID"]);
             *                  t_Decimal LastPrice = new t_Decimal(drPrice["Price"]);
             *
             *                  _DALModifyBillHeader.UpdateSMItemPrice(argsInTrans, ItemPriceID, LastPrice);
             #endregion --如果已存在记录,则更新单价 --
             *              }
             *              else
             *              {
             *                  _DALModifyBillHeader.DeleteSMItemPrice(argsInTrans, ItemPriceID);
             *              }
             *          }
             *      }
             *  }
             #endregion
             *
             *  _DALModifyBillHeader.UnApprove(argsInTrans, ModifyBillHeaderID);
             * };
             * DBHelper.ExecInTrans(args, exec);
             */
        }