Beispiel #1
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text != "")
                {
                    if (txtStoreOfQty.Text != "")
                    {
                        Shelfs _Shelfs = new Shelfs();

                        _Shelfs.Name     = txtName.Text;
                        _Shelfs.StoreQty = Convert.ToInt32(txtStoreOfQty.Text);

                        decimal AlreadyExistShelfs = _ShelfRepository.AlreadyExistName(_Shelfs);
                        if (AlreadyExistShelfs >= 1)
                        {
                            lblmsg.Text      = "This Shelfs Already Here!!....";
                            lblmsg.ForeColor = Color.Red;
                            txtName.Focus();
                        }
                        else
                        {
                            int Savesuccess = _ShelfRepository.Add(_Shelfs);
                            if (Savesuccess > 0)
                            {
                                lblmsg.Text      = "This Shelfs Save Successefully!!....";
                                lblmsg.ForeColor = Color.Green;
                                LoadShelfs();
                                txtStoreOfQty.Text = "";
                                txtName.Text       = "";

                                //Response.Redirect(Request.Url.AbsoluteUri);
                            }
                            else
                            {
                                lblmsg.Text      = "This Shelfs Saving Failed!!....";
                                lblmsg.ForeColor = Color.Red;
                            }
                        }
                    }
                    else
                    {
                        txtStoreOfQty.Focus();
                        lblmsg.Text      = "Please Type Shelfs Store Qty";
                        lblmsg.ForeColor = Color.Red;
                    }
                }
                else
                {
                    txtName.Focus();
                    lblmsg.Text      = "Please Type Shelfs Name";
                    lblmsg.ForeColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                lblmsg.Text      = ex.Message;
                lblmsg.ForeColor = Color.Red;
            }
        }