Exemplo n.º 1
0
        public void DeleteFromBranch(BranchModel branchModel)
        {
            MDBHelper = new MainDatabaseHelper();
            BranchModel branch = new BranchModel();
            SqlCommand  cmd    = new SqlCommand("Delete  from Branches where BranchID = " + branchModel.BranchID);

            //SqlCommand cmd = new SqlCommand("GetBranchInfo");
            //cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandType = CommandType.Text;
            MDBHelper.Delete(cmd, branch);
        }
Exemplo n.º 2
0
        //public static BranchCreateView Instance
        //{
        //    get
        //    {
        //        if (instance == null)
        //        {
        //            instance = new BranchCreateView();
        //        }
        //        return instance;
        //    }
        //}
        #endregion

        #region callback or event
        private void btnAdd_Click(object sender, EventArgs e)
        {
            _branchModel            = new BranchModel();
            _branchModel.BranchName = txtBranchName.Text;
            _branchModel.Address    = txtBranchAddress.Text;
            _branchModel.Contact    = txtContact.Text;
            _dbhelper = new DatabaseHelper();
            int id = _dbhelper.InsertInBranch(_branchModel, _currentUser);

            MessageBox.Show("Successfully Saved into Database" + id, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 3
0
 private void btnGetBranchID_Click(object sender, EventArgs e)
 {
     branchModel          = new BranchModel();
     branchModel.BranchID = Int32.Parse(tbBranchID.Text);
     dbhelper             = new DatabaseHelper();
     branchModel          = dbhelper.SelectAllFromBranch(branchModel, _currentUser);
     //branchModel.BranchName = tbBranchName.Text;
     //branchModel.Address = tbBranchAddress.Text;
     //branchModel.Contact = tbContact.Text;
     tbBranchAddress.Text = branchModel.Address;
     tbBranchName.Text    = branchModel.BranchName;
     tbContact.Text       = branchModel.Contact;
 }
Exemplo n.º 4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            branchModel = new BranchModel();
            dbhelper    = new DatabaseHelper();

            branchModel.BranchID   = Int32.Parse(tbBranchID.Text);
            branchModel.BranchName = tbBranchName.Text;
            branchModel.Address    = tbBranchAddress.Text;
            branchModel.Contact    = tbContact.Text;
            //int ID =
            dbhelper.UpdateInBranch(branchModel, _currentUser);
            MessageBox.Show("success");
        }
Exemplo n.º 5
0
 public void Delete(SqlCommand cmd, BranchModel branch)
 {
     try
     {
         cmd.Connection = con;
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
     }
     catch (Exception e)
     {
         MessageBox.Show("error in deleting");
         throw;
     }
 }
Exemplo n.º 6
0
        public BranchModel SelectAllFromBranch(BranchModel branchModel, UserModel currentUser)
        {
            MDBHelper = new MainDatabaseHelper();
            BranchModel branch = new BranchModel();
            SqlCommand  cmd    = new SqlCommand("Select  * from Branches where BranchID = " + branchModel.BranchID);

            //SqlCommand cmd = new SqlCommand("GetBranchInfo");
            //cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandType = CommandType.Text;
            //cmd.Parameters.AddWithValue("@branchID", branchModel.BranchID);
            //cmd.Parameters.Add("@BranchName",SqlDbType.VarChar, 100).Direction = ParameterDirection.Output;
            //cmd.Parameters.Add("@Address", SqlDbType.VarChar,100).Direction = ParameterDirection.Output;
            //cmd.Parameters.Add("@Contact", SqlDbType.VarChar,50).Direction = ParameterDirection.Output;
            branch = MDBHelper.GetDataFromBranch(cmd, branch);
            return(branch);
        }
Exemplo n.º 7
0
        public int InsertInBranch(BranchModel branchModel, UserModel currentUser)
        {
            MDBHelper = new MainDatabaseHelper();

            SqlCommand cmd = new SqlCommand("InsertBranch");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@BranchName", branchModel.BranchName);
            cmd.Parameters.AddWithValue("@Address", branchModel.Address);
            cmd.Parameters.AddWithValue("@Contact", branchModel.Contact);
            //cmd.Parameters.AddWithValue("@DepartmentID", branchModel.DepartmentID);
            cmd.Parameters.AddWithValue("@CreatedBy", currentUser.UserID);
            cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
            cmd.Parameters.AddWithValue("@ModifiedBy", currentUser.UserID);
            cmd.Parameters.AddWithValue("@ModifiedDate", DateTime.Now);
            cmd.Parameters.Add("@BranchID", SqlDbType.Int).Direction = ParameterDirection.Output;
            int BranchID = MDBHelper.RunQuerryInBranch(cmd);

            //int BranchID = int.Parse(cmd.Parameters["@BranchID"].Value.ToString());
            return(BranchID);
        }