コード例 #1
0
        public void Create(ShopeFormDTO model)
        {
            Shope dbModel = _mapper.Map <Shope>(model);

            _service.Shope.Create(dbModel);
            _service.Commit();
        }
コード例 #2
0
        public Shope GetShopeById(int shId)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_shope WHERE id=" + shId;
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            Shope         shope  = new Shope();

            while (reader.Read())
            {
                shope.ShopeId        = int.Parse(reader["id"].ToString());
                shope.ShopeCode      = reader["shope_code"].ToString();
                shope.ShopeName      = reader["shope_name"].ToString();
                shope.ShopePhone     = reader["shope_phone"].ToString();
                shope.ShopeAddress   = reader["shope_address"].ToString();
                shope.MonthlyRent    = Convert.ToDouble(reader["shope_monthly_rent"].ToString());
                shope.OpeningBalance = Convert.ToDouble(reader["shope_opening_balance"].ToString());
                break;
            }
            reader.Close();
            connection.Close();
            return(shope);
        }
コード例 #3
0
        public List <Shope> GetAllShopeInfo()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_shope";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader    = command.ExecuteReader();
            List <Shope>  shopeList = new List <Shope>();
            int           serialNo  = 1;

            while (reader.Read())
            {
                Shope shope = new Shope();
                shope.SerialNo       = serialNo++;
                shope.ShopeId        = int.Parse(reader["id"].ToString());
                shope.ShopeCode      = reader["shope_code"].ToString();
                shope.ShopeName      = reader["shope_name"].ToString();
                shope.ShopePhone     = reader["shope_phone"].ToString();
                shope.ShopeAddress   = reader["shope_address"].ToString();
                shope.MonthlyRent    = Convert.ToDouble(reader["shope_monthly_rent"].ToString());
                shope.OpeningBalance = Convert.ToDouble(reader["shope_opening_balance"].ToString());
                shopeList.Add(shope);
            }
            reader.Close();
            connection.Close();
            return(shopeList);
        }
コード例 #4
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            if (saveButton.Text == "Update")
            {
                Shope shope = new Shope();
                shope.ShopeCode      = shopeCodeTextBox.Text;
                shope.ShopeName      = shopeNameTextBox.Text;
                shope.ShopePhone     = phoneTextBox.Text;
                shope.ShopeAddress   = addressTextArea.InnerText;
                shope.MonthlyRent    = Convert.ToDouble(monthlyRentTextBox.Text);
                shope.OpeningBalance = Convert.ToDouble(openingBalanceTextBox.Text);

                shope.ShopeId = int.Parse(formWithShopIdHiddenField.Value);
                if (shopeManager.UpdateShope(shope))
                {
                    message.InnerText = "Updated Successfully!!";
                    saveButton.Text   = "Save";
                    ClearTextBoxes();
                }
                else
                {
                    message.InnerText = "No data Update in Database!!";
                }
            }
            else
            {
                InsertShope();
            }
            LoadAllShopeInfo();
        }
コード例 #5
0
 public string Save(Shope shope)
 {
     if (shopeGateway.Insert(shope) > 0)
     {
         return("Saved Successfully!!");
     }
     return("Could Not save data in Database!!");
 }
コード例 #6
0
        public bool UpdateShope(Shope shope)
        {
            bool isUpdated = false;

            if (shope.ShopeId > 0)
            {
                isUpdated = shopeGateway.UpdateShope(shope);
            }
            return(isUpdated);
        }
コード例 #7
0
        protected void updateButton_OnClick(object sender, EventArgs e)
        {
            GridViewRow clickedRow    = (GridViewRow)((LinkButton)sender).Parent.Parent;
            HiddenField shHiddenField = (HiddenField)clickedRow.FindControl("shopIdHiddenFieldGridView");
            int         shId          = int.Parse(shHiddenField.Value);
            Shope       shope         = shopeManager.GetShopeById(shId);

            if (LoadFormWithShopeId(shope))
            {
                saveButton.Text = "Update";
            }
        }
コード例 #8
0
        public int Insert(Shope shope)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "INSERT INTO tbl_shope VALUES('" + shope.ShopeCode + "','" + shope.ShopeName + "','" +
                                       shope.ShopePhone + "','" + shope.ShopeAddress + "','" + shope.MonthlyRent + "','" +
                                       shope.OpeningBalance + "')";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected);
        }
コード例 #9
0
 private bool LoadFormWithShopeId(Shope shope)
 {
     if (shope != null)
     {
         shopeCodeTextBox.Text           = shope.ShopeCode;
         shopeNameTextBox.Text           = shope.ShopeName;
         phoneTextBox.Text               = shope.ShopePhone;
         addressTextArea.InnerText       = shope.ShopeAddress;
         monthlyRentTextBox.Text         = shope.MonthlyRent.ToString();
         openingBalanceTextBox.Text      = shope.OpeningBalance.ToString();
         formWithShopIdHiddenField.Value = shope.ShopeId.ToString();
         return(true);
     }
     return(false);
 }
コード例 #10
0
        public Shope GetNextShopeCode()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT TOP 1 * FROM tbl_shope ORDER BY id DESC";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            Shope         shope  = new Shope();

            while (reader.Read())
            {
                shope.ShopeId   = int.Parse(reader["id"].ToString());
                shope.ShopeCode = reader["shope_code"].ToString();
            }
            reader.Close();
            connection.Close();
            return(shope);
        }
コード例 #11
0
        public bool UpdateShope(Shope shope)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "UPDATE tbl_shope SET shope_code='" + shope.ShopeCode + "',shope_name='" + shope.ShopeName +
                                       "',shope_phone='" + shope.ShopePhone + "',shope_address='" + shope.ShopeAddress +
                                       "',shope_monthly_rent='" + shope.MonthlyRent + "',shope_opening_balance='" +
                                       shope.OpeningBalance + "' WHERE id=" + shope.ShopeId;
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            if (rowAffected > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #12
0
        private string LoadNextShopCode()
        {
            Shope  shope  = shopeManager.GetNextShopeCode();
            string shCode = shope.ShopeCode;
            int    count;

            if (shCode == null)
            {
                count = 1;
            }
            else
            {
                count = (shCode[2] - '0') * 10 + (shCode[3] - '0') + 1;
            }

            string nextCode = "Sh" + count.ToString("00");

            return(nextCode);
        }
コード例 #13
0
        private void InsertShope()
        {
            Shope shope = new Shope();

            shope.ShopeCode    = shopeCodeTextBox.Text;
            shope.ShopeName    = shopeNameTextBox.Text;
            shope.ShopePhone   = phoneTextBox.Text;
            shope.ShopeAddress = addressTextArea.InnerText;
            string monthlyRent      = monthlyRentTextBox.Text;
            string shOpeningBalance = openingBalanceTextBox.Text;

            if (shopeCodeTextBox.Text == "" || shopeNameTextBox.Text == "" || phoneTextBox.Text == "" ||
                addressTextArea.InnerText == "" || monthlyRentTextBox.Text == "" || openingBalanceTextBox.Text == "")
            {
                message.InnerText = "All Fields are Required";
            }
            else
            {
                shope.MonthlyRent    = Convert.ToDouble(monthlyRent);
                shope.OpeningBalance = Convert.ToDouble(shOpeningBalance);
                message.InnerText    = shopeManager.Save(shope);
                LoadAllShopeInfo();
            }
        }