Esempio n. 1
0
 private void ComboDocNo_TextChanged(object sender, EventArgs e)
 {
     //Formatting Form:
     if (ComboDocNo.Text == "")
     {
         BtnDelete.Enabled = false;
     }
     else
     {
         BtnDelete.Enabled = true;
     }
     if (TxtPredicationOrder.Text == "" || ComboLocation.Text == "" || ComboContractor.Text == "" ||
         TxtExcuteOrder.Text == "" || TxtPeriod.Text == "0" || ComboDocNo.Text == "" ||
         TxtOperation.Text == "" || TxtAmount.Text == "0" || ComboReservedRefund.Text == "" ||
         ComboInsuranceRefund.Text == "" || TxtJustAmount.Text == "")
     {
         BtnUpdate.Enabled = false;
     }
     else
     {
         BtnUpdate.Enabled = true;
     }
     //
     // Loading data to form:
     //
     try
     {
         using (DBAuditDataContext dc = new DBAuditDataContext())
         {
             if (ComboDocNo.Text != "")
             {
                 int?     IntLocationID         = null;
                 int?     IntContractorID       = null;
                 string   StrExcuteOrder        = null;
                 DateTime?VarExcuteDate         = null;
                 string   StrPredicationOder    = null;
                 DateTime?VarPredicationDate    = null;
                 int?     IntPeriod             = null;
                 DateTime?VarStartDate          = null;
                 DateTime?VarEndDate            = null;
                 int?     IntActualPeriod       = null;
                 string   StrName               = null;
                 decimal? DecimalValue          = null;
                 DateTime?VarDatePay            = null;
                 decimal? DecimalTaxRate        = null;
                 decimal? DecimalTaxValue       = null;
                 decimal? DecimalTransFeesRate  = null;
                 decimal? DecimalTransFeesValue = null;
                 decimal? DecimalInsuranceRate  = null;
                 decimal? DecimalInsuranceValue = null;
                 string   StrInsuranceRefund    = null;
                 decimal? DecimalReservedRate   = null;
                 decimal? DecimalReservedValue  = null;
                 string   StrReservedRefund     = null;
                 decimal? DecimalBusinessFees   = null;
                 decimal? DecimalTotalDiscount  = null;
                 decimal? DecimalNetAmount      = null;
                 string   StrJustAmount         = null;
                 string   StrReservedDocNo      = null;
                 DateTime?VarReservedPayDate    = null;
                 decimal? DecimalResDiscPercent = null;
                 decimal? DecimalResDiscount    = null;
                 decimal? DecimalResPaid        = null;
                 string   StrInsDocNo           = null;
                 DateTime?varInsurancePayDate   = null;
                 decimal? DecimalInsDiscPercent = null;
                 decimal? DecimalInsDiscount    = null;
                 decimal? DecimalInsurancePaid  = null;
                 string   StrNotes              = null;
                 string   StrLocation           = null;
                 string   StrContractor         = null;
                 dc.ProSelectProject(ref IntLocationID, ref IntContractorID, ref StrExcuteOrder,
                                     ref VarExcuteDate, ref StrPredicationOder, ref VarPredicationDate, ref IntPeriod,
                                     ComboDocNo.SelectedValue.ToString(), ref VarStartDate, ref VarEndDate, ref IntActualPeriod, ref StrName,
                                     ref DecimalValue, ref VarDatePay, ref DecimalTaxRate, ref DecimalTaxValue,
                                     ref DecimalTransFeesRate, ref DecimalTransFeesValue, ref DecimalInsuranceRate,
                                     ref DecimalInsuranceValue, ref StrInsuranceRefund, ref DecimalReservedRate,
                                     ref DecimalReservedValue, ref StrReservedRefund, ref DecimalBusinessFees,
                                     ref DecimalTotalDiscount, ref DecimalNetAmount, ref StrJustAmount, ref StrReservedDocNo,
                                     ref VarReservedPayDate, ref DecimalResDiscPercent, ref DecimalResDiscount,
                                     ref DecimalResPaid, ref StrInsDocNo, ref varInsurancePayDate, ref DecimalInsDiscPercent,
                                     ref DecimalInsDiscount, ref DecimalInsurancePaid, ref StrNotes);
                 TxtExcuteOrder.Text         = StrExcuteOrder;
                 DateExcuteOrder.Value       = VarExcuteDate.Value;
                 TxtPredicationOrder.Text    = StrPredicationOder;
                 DatePredicationOreder.Value = VarPredicationDate.Value;
                 TxtPeriod.Text            = IntPeriod.ToString();
                 DateStart.Value           = VarStartDate.Value;
                 DateEnd.Value             = VarEndDate.Value;
                 TxtActualPeriod.Text      = IntActualPeriod.ToString();
                 TxtOperation.Text         = StrName;
                 TxtAmount.Text            = DecimalValue.ToString();
                 DatePay.Value             = VarDatePay.Value;
                 TxtTaxRate.Text           = DecimalTaxRate.ToString();
                 TxtTaxAmount.Text         = DecimalTaxValue.ToString();
                 TxtTransRate.Text         = DecimalTransFeesRate.ToString();
                 TxtTransAmount.Text       = DecimalTransFeesValue.ToString();
                 TxtInsurRate.Text         = DecimalInsuranceRate.ToString();
                 TxtInsurAmount.Text       = DecimalInsuranceValue.ToString();
                 ComboReservedRefund.Text  = StrInsuranceRefund;
                 TxtReservedRate.Text      = DecimalReservedRate.ToString();
                 TxtReservedAmount.Text    = DecimalReservedValue.ToString();
                 ComboInsuranceRefund.Text = StrReservedRefund;
                 TxtBusinessFees.Text      = DecimalBusinessFees.ToString();
                 TxtTotalDiscount.Text     = DecimalTotalDiscount.ToString();
                 TxtNetAmount.Text         = DecimalNetAmount.ToString();
                 TxtJustAmount.Text        = StrJustAmount;
                 TxtReservedDocNo.Text     = StrReservedDocNo;
                 if (VarReservedPayDate != null)
                 {
                     DateResevedPay.Value = VarReservedPayDate.Value;
                 }
                 else
                 {
                     DateResevedPay.Value = DateTime.Now;
                 }
                 TxtResDiscountPercentage.Text = DecimalResDiscPercent.ToString();
                 TxtResDiscountAmount.Text     = DecimalResDiscount.ToString();
                 TxtReservedPaid.Text          = DecimalResPaid.ToString();
                 TxtInsuranceDocNo.Text        = StrInsDocNo;
                 if (varInsurancePayDate != null)
                 {
                     DateInsurancePay.Value = varInsurancePayDate.Value;
                 }
                 else
                 {
                     DateInsurancePay.Value = DateTime.Now;
                 }
                 TxtInsurDiscountPercentage.Text = DecimalInsDiscPercent.ToString();
                 TxtInsuranceDiscountAmount.Text = DecimalInsDiscount.ToString();
                 TxtInsurancePaid.Text           = DecimalInsurancePaid.ToString();
                 TxtNotes.Text = StrNotes;
                 DatePay.Value = VarDatePay.Value;
                 var d = dc.ProGetLocationByID(IntLocationID, ref StrLocation);
                 ComboLocation.Text = StrLocation;
                 var x = dc.ProGetContractorByID(IntContractorID, ref StrContractor);
                 ComboContractor.Text = StrContractor;
                 TxtNotes.Text        = StrNotes;
             }
             else
             {
                 ComboLocation.Text        = "";
                 ComboContractor.Text      = "";
                 TxtExcuteOrder.Text       = "";
                 DateExcuteOrder.Value     = DatePredicationOreder.Value =
                     DateStart.Value       = DateEnd.Value = DatePay.Value = DateTime.Now;
                 TxtPredicationOrder.Text  = "";
                 TxtPeriod.Text            = "0";
                 TxtActualPeriod.Text      = "";
                 TxtOperation.Text         = "";
                 TxtAmount.Text            = "0.00";
                 TxtTaxAmount.Text         = "0.00";
                 TxtTransAmount.Text       = "0.00";
                 TxtInsurAmount.Text       = "0.00";
                 ComboReservedRefund.Text  = "";
                 TxtReservedAmount.Text    = "0.00";
                 ComboInsuranceRefund.Text = "";
                 TxtBusinessFees.Text      = "0.00";
                 TxtTotalDiscount.Text     = "0.00";
                 TxtNetAmount.Text         = "0.00";
                 TxtJustAmount.Text        = "";
                 TxtReservedDocNo.Text     = null;
                 DateResevedPay.Value      = DateTime.Now;
                 ;
                 TxtResDiscountPercentage.Text   = null;
                 TxtResDiscountAmount.Text       = null;
                 TxtReservedPaid.Text            = null;
                 TxtInsuranceDocNo.Text          = null;
                 DateInsurancePay.Value          = DateTime.Now;
                 TxtInsurDiscountPercentage.Text = null;
                 TxtInsuranceDiscountAmount.Text = null;
                 TxtInsurancePaid.Text           = null;
                 TxtNotes.Text = null;
             }
         }
     }
     catch (NullReferenceException)
     {
     }
     catch (InvalidOperationException IEX)
     {
         MessageBox.Show(IEX.Message);
         ComboLocation.Text        = "";
         ComboContractor.Text      = "";
         TxtExcuteOrder.Text       = "";
         DateExcuteOrder.Value     = DatePredicationOreder.Value =
             DateStart.Value       = DateEnd.Value = DatePay.Value = DateTime.Now;
         TxtPredicationOrder.Text  = "";
         TxtPeriod.Text            = "0";
         TxtActualPeriod.Text      = "";
         TxtOperation.Text         = "";
         TxtAmount.Text            = "0.00";
         TxtTaxAmount.Text         = "0.00";
         TxtTransAmount.Text       = "0.00";
         TxtInsurAmount.Text       = "0.00";
         ComboReservedRefund.Text  = "";
         TxtReservedAmount.Text    = "0.00";
         ComboInsuranceRefund.Text = "";
         TxtBusinessFees.Text      = "0.00";
         TxtTotalDiscount.Text     = "0.00";
         TxtNetAmount.Text         = "0.00";
         TxtJustAmount.Text        = "";
         TxtReservedDocNo.Text     = null;
         DateResevedPay.Value      = DateTime.Now;
         ;
         TxtResDiscountPercentage.Text   = null;
         TxtResDiscountAmount.Text       = null;
         TxtReservedPaid.Text            = null;
         TxtInsuranceDocNo.Text          = null;
         DateInsurancePay.Value          = DateTime.Now;
         TxtInsurDiscountPercentage.Text = null;
         TxtInsuranceDiscountAmount.Text = null;
         TxtInsurancePaid.Text           = null;
         TxtNotes.Text     = "";
         BtnDelete.Enabled = false;
     }
     catch (Exception EX)
     {
         MessageBox.Show(EX.Message);
         ComboLocation.Text        = "";
         ComboContractor.Text      = "";
         TxtExcuteOrder.Text       = "";
         DateExcuteOrder.Value     = DatePredicationOreder.Value =
             DateStart.Value       = DateEnd.Value = DatePay.Value = DateTime.Now;
         TxtPredicationOrder.Text  = "";
         TxtPeriod.Text            = "0";
         TxtActualPeriod.Text      = "";
         TxtOperation.Text         = "";
         TxtAmount.Text            = "0.00";
         TxtTaxAmount.Text         = "0.00";
         TxtTransAmount.Text       = "0.00";
         TxtInsurAmount.Text       = "0.00";
         ComboReservedRefund.Text  = "";
         TxtReservedAmount.Text    = "0.00";
         ComboInsuranceRefund.Text = "";
         TxtBusinessFees.Text      = "0.00";
         TxtTotalDiscount.Text     = "0.00";
         TxtNetAmount.Text         = "0.00";
         TxtJustAmount.Text        = "";
         TxtReservedDocNo.Text     = null;
         DateResevedPay.Value      = DateTime.Now;
         ;
         TxtResDiscountPercentage.Text   = null;
         TxtResDiscountAmount.Text       = null;
         TxtReservedPaid.Text            = null;
         TxtInsuranceDocNo.Text          = null;
         DateInsurancePay.Value          = DateTime.Now;
         TxtInsurDiscountPercentage.Text = null;
         TxtInsuranceDiscountAmount.Text = null;
         TxtInsurancePaid.Text           = null;
         TxtNotes.Text     = "";
         BtnDelete.Enabled = false;
     }
 }