protected void btnSave_Click(object sender, EventArgs e)
        {
            CostCenter objCenter=new CostCenter();

            objCenter.CostCenterType = txtCostCenterType.Value;
            objCenter.CostCenterName = txtCostCentreName.Value;
            objCenter.IsActive = chkIsActive.Checked;
            objCenter.CompanyId = _company.CompanyId;
            objCenter.UpdateBy = _user.UserId;
            objCenter.UpdateDate=DateTime.Now.Date;

            int sucess = 0;
            if (lblId.Text == "" || lblId.Text == "0")
            {
                objCenter.CostCenterId = new CostCenter().GetMaxCostCenterId() + 1;

                sucess = objCenter.InsertCostCenter();

                if (sucess > 0)
                {
                    Alert.Show("Cost Center saved successfully");

                }
            }
            else
            {
                objCenter.CostCenterId = int.Parse(lblId.Text);
                sucess = objCenter.UpdateCostCenter();

                if (sucess > 0)
                {
                    Response.Redirect("CostCenterList.aspx", true);
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CostCenter objCenter=new CostCenter();

            objCenter.CostCenterId = listCenter.Count;
            objCenter.CostCenterType = txtCostCenterType.Value;
            objCenter.CostCenterName = txtCostCentreName.Value;
            objCenter.IsActive = chkIsActive.Checked;
            objCenter.CompanyId = _company.CompanyId;
            objCenter.UpdateBy = _user.UserId;
            objCenter.UpdateDate=DateTime.Now.Date;

            int success = objCenter.InsertCostCenter();

            if (success > 0)
            {
                Alert.Show("Cost Center Inserted");
                this.GetAllCostCentre();
                this.LoadCostCentreTable();
            }
        }
        protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem item = (GridDataItem)e.Item;

            string id = item["colId"].Text;

            switch (e.CommandName)
            {
                case "btnSelect":
                    Response.Redirect("CostCenterInfo.aspx?id=" + id, true);
                    break;
                case "btnDelete":
                    int delete = new CostCenter().DeleteCostCenterByCostCenterId(int.Parse(id));

                    if (delete == 0)
                    {
                        Alert.Show("Data was not delete..");
                    }
                    else
                        LoadCostCentreTable();
                    break;
            }
        }
        private void LoadCostCentreTable()
        {
            try
            {

                CostCenter costCenter=new CostCenter();
                objCostCenterList = costCenter.GetAllCostCenter(_company.CompanyId);
                if (objCostCenterList.Count == 0)
                    objCostCenterList.Add(new CostCenter());

                RadGrid1.DataSource = objCostCenterList;
                RadGrid1.Rebind();
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
 void GetAllCostCentre()
 {
     CostCenter center=new CostCenter();
     listCenter = center.GetAllCostCenter(_user.CompanyId);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _company = (Company)Session["Company"];
            _user = (Users)Session["user"];
            if (!isValidSession())
            {
                string str = Request.QueryString.ToString();
                if (str == string.Empty)
                    Response.Redirect("LogIn.aspx?refPage=default.aspx");
                else
                    Response.Redirect("LogIn.aspx?refPage=default.aspx?" + str);
            }
            if (!IsPostBack)
            {

                if (Request.QueryString["id"] != null)
                {
                    string costCenterId = Request.QueryString["id"].ToString();

                    CostCenter costCenter = new CostCenter().GetCostCenterByCostCenterId(int.Parse(costCenterId), _company.CompanyId);
                    if (costCenter != null || costCenter.CostCenterId != 0)
                    {
                        lblId.Text = costCenter.CostCenterId.ToString();
                        txtCostCenterType.Value = costCenter.CostCenterType;
                        txtCostCentreName.Value = costCenter.CostCenterName;
                    }
                }
            }
            this.GetAllCostCentre();
        }
        private void LoadCostCenterDropDownList()
        {
            try
            {
                CostCenter aCost = new CostCenter();
                List<CostCenter> costCenterList = aCost.GetAllCostCenter(_company.CompanyId);
                costCenterDropDownList.DataSource = costCenterList;
                costCenterDropDownList.DataTextField = "CostCenterName";
                costCenterDropDownList.DataValueField = "CostCenterId";
                costCenterDropDownList.DataBind();

            }
            catch (Exception exp)
            {
                Alert.Show(exp.Message);
            }
        }