コード例 #1
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                ImageFileUpload.SaveAs(Server.MapPath("~/Party/Images/") + Path.GetFileName(ImageFileUpload.FileName));
                String GetImagePath = "~/Party/Images/" + Path.GetFileName(ImageFileUpload.FileName);

                Customers _Customers = new Customers();
                _Customers.Code         = txtCode.Text;
                _Customers.Name         = txtName.Text;
                _Customers.Email        = txtEmail.Text;
                _Customers.Address      = txtAddress.Text;
                _Customers.Contact      = txtContact.Text;
                _Customers.LoyaltyPoint = Convert.ToDecimal(txtLoyaltyPoint.Text);
                _Customers.Images       = GetImagePath;

                if (IdHiddenField.Value == "")
                {
                    decimal AlreadyExistCustomer = _CustomerRepository.AlreadyExistCustomer(_Customers);
                    if (AlreadyExistCustomer >= 1)
                    {
                        ShowMessage("This Customer Already Here!!...Enter Another Name", MessageType.Warning);
                    }
                    else
                    {
                        int Savesuccess = _CustomerRepository.Add(_Customers);
                        if (Savesuccess > 0)
                        {
                            ShowMessage("Successfully Save Customer!!...Continue Working", MessageType.Success);
                            IdHiddenField.Value = "";
                            Refresh();
                            AutoCodeGenerate();
                            LoadCustomers();
                        }
                        else
                        {
                            ShowMessage("Failed Customer Saved!!...Try Again", MessageType.Failed);
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, MessageType.Error);
            }
        }