Esempio n. 1
0
        private void frmSearchClient_Load(object sender, EventArgs e)
        {
            toolTip1.SetToolTip(this.txtSearchclient, "Enter client name");
            toolTip1.SetToolTip(this.btnSearch, "Click to search client");
            toolTip1.SetToolTip(this.btnMaintain, "Click to edit or remove client");

            dgvClientSearch.DataSource = db.Load_Client().ToList();
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            // var q = db.Clients.Where(x => x.Client_Name == txtName.Text).ToList();

            Client                NewCllient           = new Client();
            Credit_Approval       NewCA                = new Credit_Approval();
            Credit_Approval       Credit_Approval_Form = new Credit_Approval();
            City                  newCity              = new City();
            Credit_Status         crStatus             = new Credit_Status();
            Client_Account_Status cAS     = new Client_Account_Status();
            Province              NewProv = new Province();

            if (txtName.Text == "" || txtVatRegNum.Text == "" || txtTelephone.Text == "" || txtFaxNumber.Text == "" || txtEmailAdd.Text == "" || txtPhysicalAdd.Text == "")
            {
                MessageBox.Show("Please enter all fields!");
            }
            else if (db.Load_Client().Where(x => x.VAT_Registration_No_ == txtVatRegNum.Text).ToList() == null)
            {
                try
                {
                    //  NewCA.Credit_Approval_Form = Convert.ToString(txtFilePath.Text);
                    // txtFilePath.Text = Convert.ToBase64String(NewCA.Credit_Approval_Form);
                    //  NewCA.Credit_Approval_Form = Encoding.ASCII.GetBytes(txtFilePath.Text);

                    NewCA.Credit_Approval_Amount = Convert.ToInt32(txtCreditAmount.Text);
                    NewCA.Date_Of_Commencement   = txtDateTimeDateOfCommencement.Value.Date;
                    db.Credit_Approval.Add(NewCA);


                    NewCllient.Client_Name           = txtName.Text;
                    NewCllient.Client_VAT_Reg_Number = txtVatRegNum.Text;
                    NewCllient.Client_Telephone      = "+27" + txtTelephone.Text;
                    NewCllient.Client_Fax_Number     = txtFaxNumber.Text;
                    NewCllient.Client_Email_Address  = txtEmailAdd.Text;
                    NewCllient.Physical_Address      = txtPhysicalAdd.Text;

                    NewCllient.Province_Id       = Convert.ToInt32(cbxProvince.SelectedValue.ToString());
                    NewCllient.City_Id           = Convert.ToInt32(cbxCity.SelectedValue);
                    NewCllient.Account_Status_ID = Convert.ToInt32(cbxAccountStatus.SelectedValue);



                    NewCllient.Credit_Approval_ID = NewCA.Credit_Approval_ID;

                    db.Clients.Add(NewCllient);


                    db.SaveChanges();

                    MessageBox.Show("Client Has been Added succesfully");


                    //Audit Log
                    int    Client_Id    = NewCllient.Client_ID;
                    string client_Value = Convert.ToString(NewCllient);

                    Audit_Log Current_Audit3 = new Audit_Log();
                    Current_Audit3.Table_Name = "Client";
                    // Current_Audit3.Users_Id = Globals.Users_Id;
                    Current_Audit3.Date_Time = DateTime.Now;
                    db.Audit_Log.Add(Current_Audit3);
                    db.SaveChanges();
                    int Log_ID3 = Current_Audit3.Audit_Log_Id;


                    Audit_Create_Delete Current_Create3 = new Audit_Create_Delete();
                    Current_Create3.Audit_Log_Id    = Log_ID3;
                    Current_Create3.Created         = true;
                    Current_Create3.PK_Row_Effected = Client_Id;
                    Current_Create3.Value           = client_Value;
                    db.Audit_Create_Delete.Add(Current_Create3);
                    db.SaveChanges();
                    this.Close();
                    this.Hide();
                    //MessageBox.Show("Are you sure you want to add this client ?", "confirmation", MessageBoxButtons.YesNo);
                    //MessageBox.Show("Client details have been added successfully");
                    //MessageBox.Show("Client already exists on the system");
                    //MessageBox.Show("Please fill in all required fields");
                    //MessageBox.Show("Please select a client");
                }
                catch (Exception)
                {
                }
            }
            else
            {
                MessageBox.Show("The Client with the VAT Registration Number: " + txtVatRegNum.Text + " already exists in the database");
            }
        }