コード例 #1
0
ファイル: DamagedCrops.aspx.cs プロジェクト: abigabaw/wis
        public static string[] GetUnitName(string Units)
        {
            string[]    Ids            = Units.Split('|');
            int         cropID         = Convert.ToInt32(Ids[0]);
            int         CropDesID      = Convert.ToInt32(Ids[1]);
            CropNameBLL objCropNameBLL = new CropNameBLL();
            CropNameBO  objCropname    = objCropNameBLL.GetCropNameById(cropID);

            string[] arrCrop         = { "", "" };
            string   unitMeasureName = "";
            string   cropRate        = "";

            CropRateBLL objCropRateBLL = new CropRateBLL();
            CropRateBO  objCropRateBO  = objCropRateBLL.GetCropRateByDistrict(cropID, CropDesID, Convert.ToInt32(HttpContext.Current.Session["HH_ID"]));

            if (objCropname != null)
            {
                unitMeasureName = objCropname.UnitName;
                if (objCropRateBO != null)
                {
                    cropRate = objCropRateBO.CropRate;
                }
            }

            arrCrop[0] = unitMeasureName;
            arrCrop[1] = cropRate;

            return(arrCrop);
        }
コード例 #2
0
        /// <summary>
        /// Update Database Make data as Obsoluted
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void IsObsolete_CheckedChanged(Object sender, EventArgs e)
        {
            string message = string.Empty;

            try
            {
                CheckBox    chk = (CheckBox)sender;
                GridViewRow gr  = (GridViewRow)chk.Parent.Parent;

                string      cropRateID     = ((Literal)gr.FindControl("ltlObsolete")).Text;
                CropRateBLL objCropRateBLL = new CropRateBLL();
                message = objCropRateBLL.ObsoleteCropRate(Convert.ToInt32(cropRateID), Convert.ToString(chk.Checked));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data updated successfully";
                }

                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }

                BindGrid();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        /// <summary>
        /// Set Grid Data source
        /// </summary>
        /// <param name="addRow"></param>
        /// <param name="deleteRow"></param>e
        private void BindGrid()
        {
            CropRateBO  objCRBO  = new CropRateBO();
            CropRateBLL objCRBLL = new CropRateBLL();

            grdCropRate.DataSource = objCRBLL.GetCropRate(Convert.ToInt32(ViewState["CROPID"]));
            grdCropRate.DataBind();
        }
コード例 #4
0
        /// <summary>
        /// To save details to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click1(object sender, EventArgs e)
        {
            string message = "";

            CropRateBO objCRBO = new CropRateBO();

            objCRBO.CropRateID        = int.Parse(ViewState["CROPRATEID"].ToString());
            objCRBO.CropID            = int.Parse(ViewState["CROPID"].ToString());
            objCRBO.DistrictID        = Convert.ToInt32(ddlDistrict.SelectedItem.Value);
            objCRBO.CropDescriptionID = Convert.ToInt32(ddlCropDescription.SelectedItem.Value);
            objCRBO.CropRate          = txtCropRate.Text.Trim();

            CropRateBLL objCRBLL = new CropRateBLL();

            if (objCRBO.CropRateID == 0)
            {
                objCRBO.CreatedBy = Convert.ToInt32(Session["USER_ID"]);

                message = objCRBLL.AddCropRate(objCRBO);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data saved successfully.";
                }

                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }
            }
            else
            {
                objCRBO.UpdatedBy = Convert.ToInt32(Session["USER_ID"]);

                message = objCRBLL.UpdateCropRate(objCRBO);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data updated successfully.";
                }

                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "alert('" + message + "');", true);
                }
                SetUpdateMode(false);
            }

            ClearDetails();
            BindGrid();
        }
コード例 #5
0
        /// <summary>
        /// Set edit mode for edit comand
        /// Delete data from the database for delete comand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdCropRate_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditRow")
            {
                ViewState["CROPRATEID"] = e.CommandArgument;
                CropRateBO  objCRBO  = new CropRateBO();
                CropRateBLL objCRBLL = new CropRateBLL();
                objCRBO = objCRBLL.GetCropRateByID(Convert.ToInt32(ViewState["CROPRATEID"]));
                if (objCRBO != null)
                {
                    txtCropRate.Text = objCRBO.CropRate;

                    ddlDistrict.ClearSelection();
                    if (ddlDistrict.Items.FindByValue(objCRBO.DistrictID.ToString()) != null)
                    {
                        ddlDistrict.Items.FindByValue(objCRBO.DistrictID.ToString()).Selected = true;
                    }

                    ddlCropDescription.ClearSelection();
                    if (ddlCropDescription.Items.FindByValue(objCRBO.CropDescriptionID.ToString()) != null)
                    {
                        ddlCropDescription.Items.FindByValue(objCRBO.CropDescriptionID.ToString()).Selected = true;
                    }
                }
                SetUpdateMode(true);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Added", "setDirty();", true);
            }

            else if (e.CommandName == "DeleteRow")
            {
                string message = string.Empty;

                CropRateBLL objCRBLL = new CropRateBLL();
                message = objCRBLL.DeleteCropRate(Convert.ToInt32(e.CommandArgument));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data deleted successfully";
                }

                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }
                ClearDetails();
                BindGrid();
            }
        }