Beispiel #1
0
 public bool insertR(RCB_Table robj)
 {
     obj.RCB_Table.Add(robj);
     return(obj.SaveChanges() > 0);
 }
Beispiel #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            ForceValidation();
            if (Validation.GetHasError(cbRegNo) || Validation.GetHasError(txtName) ||
                Validation.GetHasError(txtPhone) || Validation.GetHasError(txtAddress) ||
                Validation.GetHasError(dpDOI) || Validation.GetHasError(dpDOR) ||
                Validation.GetHasError(txtRPD) || Validation.GetHasError(cbTax))
            {
                MessageBox.Show("Error Some Data is Missing", "ERROR");
                return;
            }
            Customer_Table cObj    = new Customer_Table();
            RCB_Table      rObj    = new RCB_Table();
            CarFactory     cartFac = new CarFactory();

            rObj.CA_ID = int.Parse(cbRegNo.SelectedValue.ToString());
            cartFac.ChangeStatus(rObj.CA_ID, false);
            cObj.C_Name    = txtName.Text.Trim();
            cObj.C_Address = txtAddress.Text.Trim();
            cObj.C_Phone   = txtPhone.Text.Trim();
            RCB_Factory obj    = new RCB_Factory();
            bool        result = obj.insertC(cObj);

            rObj.C_ID = cObj.C_ID;
            DateTime issue, retrn;

            issue = DateTime.Parse(dpDOI.Text);
            retrn = DateTime.Parse(dpDOR.Text);
            if (issue.Date > retrn.Date)
            {
                MessageBox.Show("Issue Date is Greater than Return Date", "Error");
            }
            else
            {
                rObj.RCB_DOI = issue;
                rObj.RCB_DOR = retrn;
            }
            TimeSpan ts = retrn - issue;
            decimal  td = ts.Days;
            decimal  rpd;

            rpd             = decimal.Parse(txtRPD.Text);
            rObj.RCB_RentPD = rpd;
            decimal total;

            total = rpd * td;
            // TotalB.Text = total.ToString();

            rObj.T_ID = int.Parse(cbTax.SelectedValue.ToString());
            decimal tax = decimal.Parse(cbTax.Text.ToString());

            tax /= 100;
            //decimal taxd = decimal.Parse(tax.ToString());
            decimal taxp = (total * tax);

            total += taxp;

            rObj.RCB_TotalBill = total;
            totalTemp          = total;
            TotalB.Text        = totalTemp.ToString();
            bool rResult = obj.insertR(rObj);

            if (rResult && result)
            {
                MessageBox.Show("Data is Added Successfully", "Saved");
                txtName.Text         = null;
                cbRegNo.SelectedItem = null;
                this.Close();
            }
            else
            {
                MessageBox.Show("Data is not Added", "Error");
            }
        }
Beispiel #3
0
 public RCB_DA()
 {
     cobj = new Customer_Table();
     robj = new RCB_Table();
     obj  = new AutoDealershipEntities();
 }