Пример #1
0
        public static Entity.Customer.Contract GetById(int contractId)
        {
            Entity.Customer.Contract contract = new Entity.Customer.Contract();
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Parameters.AddWithValue("@ContractTypeId", contractId);

                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "usp_Customer_ContractType_GetById";
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr.HasRows)
                        {
                            contract.ContractId   = contractId;
                            contract.ContractName = dr["ContractName"].ToString();
                            contract.Description  = (dr["Description"] == DBNull.Value) ? "" : dr["Description"].ToString();
                        }
                    }
                    con.Close();
                }
            }
            return(contract);
        }
Пример #2
0
        public static int Save(Entity.Customer.Contract contract)
        {
            int rowsAffacted = 0;

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandText = "usp_Customer_ContractType_Save";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@ContractTypeId", contract.ContractId);
                    cmd.Parameters.AddWithValue("@ContractName", contract.ContractName);
                    cmd.Parameters.AddWithValue("@Description", contract.Description);

                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    rowsAffacted = cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
            return(rowsAffacted);
        }
        protected void gvContract_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                Business.Customer.Contract objContract = new Business.Customer.Contract();
                Entity.Customer.Contract   contract    = new Entity.Customer.Contract();

                if (e.CommandName == "Ed")
                {
                    int brandId = int.Parse(e.CommandArgument.ToString());
                    contract             = objContract.GetById(brandId);
                    ContractId           = contract.ContractId;
                    txtContractName.Text = contract.ContractName;
                    txtDescription.Text  = contract.Description;
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Business.Customer.Contract objContract = new Business.Customer.Contract();
                Entity.Customer.Contract   contract    = new Entity.Customer.Contract();

                contract.ContractId   = ContractId;
                contract.ContractName = txtContractName.Text;
                contract.Description  = txtDescription.Text;

                int i = objContract.Save(contract);

                if (i > 0)
                {
                    ClearControls();
                    LoadContract();
                    Message.IsSuccess = true;
                    Message.Text      = "Contract Information saved successfully...";
                }
                else
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Can not save!!!";
                }
                Message.Show = true;
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
Пример #5
0
 public int Save(Entity.Customer.Contract contract)
 {
     return(DataAccess.Customer.Contract.Save(contract));
 }