Esempio n. 1
0
 private int insertToDB()
 {
     DTO.Invoice invoice = new DTO.Invoice();
     System.Collections.ArrayList details = new System.Collections.ArrayList();
     for (int i = 0; i < grdItems.Rows.Count; i++)
     {
         DTO.InvoiceDetail d = new DTO.InvoiceDetail();
         DTO.Product p = new DTO.Product();
         p.Productid = int.Parse(grdItems.Rows[i].Cells[7].Value.ToString());
         d.Quantity = int.Parse(grdItems.Rows[i].Cells[2].Value.ToString());
         d.Priceout = decimal.Parse(grdItems.Rows[i].Cells[3].Value.ToString());
         d.Dicount = decimal.Parse(grdItems.Rows[i].Cells[4].Value.ToString());
         d.Pricein = decimal.Parse(grdItems.Rows[i].Cells[8].Value.ToString());
         d.Product = p;
         details.Add(d);
     }
     
     DTO.Member member = new DTO.Member();
     member.Memberid = (int)cboMember.SelectedValue;            ///
     invoice.Staff = UserSession.Session.Staff;
     invoice.Member = member;
     invoice.Remark = "";
     invoice.Discount = decimal.Parse(txtDiscount.Text.Replace("%", "").Replace(" ",""));
     invoice.InvoiceDetail = details;
     return new DAO.InvoiceDAO().addInvoice(invoice);
 }
Esempio n. 2
0
 public void OnItem_Selected(object sender, SelectedItemChangedEventArgs e)
 {
     try
     {
         Member member;
         if (e.SelectedItem != null)
         {
             member = new DTO.Member();
             member = e.SelectedItem as Member;
             //DisplayAlert("Notification", "You Select " + name, "No", "Yes");
             Navigation.PushAsync(new ShowMember(member));
         }
     }
     catch { }
 }
Esempio n. 3
0
 private void Save_Click(object sender, EventArgs e)
 {
     if (id == 0)
     {
         if (txtName.Text == "" || txtPhone.Text == "" || txtCode.Text == "")
         {
             MessageBox.Show("សូមបំពេញពត៏មានឲ្យបានត្រឹមត្រូវ!!!");
         }
         else
         {
             DTO.Member member = new DTO.Member();
             member.Membername = txtName.Text;
             member.MemberCode = txtCode.Text;
             member.Phonenumber = txtPhone.Text;
             DTO.Staff staff = new DTO.Staff();
             staff.Staffid = UserSession.Session.Staff.Staffid;
             member.Createdby = staff;
             member.MemberTypeId = (int)cbMemberType.SelectedValue;
             decimal discount = 0;
             if (txtDiscountRate.Text != "")
             {
                 discount = System.Convert.ToDecimal(txtDiscountRate.Text);
             }
             member.Discountrate = discount;
             if (new MemberDAO().addMember(member))
             {
                 txtName.Clear();
                 txtCode.Clear();
                 txtDiscountRate.Clear();
                 txtPhone.Clear();
                 dgvMember.DataSource = new DAO.MemberDAO().getAllMembersWithDataSet().Tables[0];
                 id = 0;
             }
             else
             {
                 MessageBox.Show("ប្រតិបត្តិការណ៍បរាជ័យ!!!");
             }
         }
     }
     else
     {
         DTO.Member member = new DTO.Member();
         member.Membername = txtName.Text;
         member.MemberCode = txtCode.Text;
         member.Phonenumber = txtPhone.Text;
         DTO.Staff staff = new DTO.Staff();
         staff.Staffid = UserSession.Session.Staff.Staffid;
         member.Updatedby = staff;
         member.Memberid = id;
         decimal discount = 0;
         if (txtDiscountRate.Text != "")
         {
             discount = System.Convert.ToDecimal(txtDiscountRate.Text);
         }
         member.Discountrate = discount;
         member.MemberTypeId = (int)cbMemberType.SelectedValue;
         if (new MemberDAO().updateMemeber(member))
         {
             txtName.Clear();
             txtCode.Clear();
             txtDiscountRate.Clear();
             txtPhone.Clear();
             dgvMember.DataSource = new DAO.MemberDAO().getAllMembersWithDataSet().Tables[0];
             id = 0;
             delete.Visible = false;
         }
         else
         {
             MessageBox.Show("ប្រតិបត្តិការណ៍បរាជ័យ!!!");
         }
     }
 }