Ejemplo n.º 1
0
        //private void Getunitofmeasure()
        //{
        //    UnitBLL BLLobj = new UnitBLL();

        //    ddlUnitOfmeasure.DataSource = BLLobj.GetUnit();
        //    ddlUnitOfmeasure.DataTextField = "UnitName";
        //    ddlUnitOfmeasure.DataValueField = "UnitID";
        //    ddlUnitOfmeasure.DataBind();
        //}
        /// <summary>
        /// Set Grid Data source
        /// </summary>
        /// <param name="addRow"></param>
        /// <param name="deleteRow"></param>e
        private void BindGrid()
        {
            CropTypeBLL CropTypeBLLObj = new CropTypeBLL();

            gvCropType.DataSource = CropTypeBLLObj.GetAllCropDetails();
            gvCropType.DataBind();
        }
Ejemplo n.º 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      CROPTYPEID     = ((Literal)gr.FindControl("ltlObsolete")).Text;
                CropTypeBLL objCropTypeBLL = new CropTypeBLL();
                message = objCropTypeBLL.ObsoleteCropType(Convert.ToInt32(CROPTYPEID), 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;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// to fetch values to dropdownlist
        /// </summary>
        private void GetCropType()
        {
            CropTypeBLL BLLobj = new CropTypeBLL();

            ddlCropType.DataSource     = BLLobj.GetCropDetails();
            ddlCropType.DataTextField  = "CropType";
            ddlCropType.DataValueField = "CROPTYPEID";
            ddlCropType.DataBind();
        }
Ejemplo n.º 4
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 gvCropType_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditRow")
            {
                ViewState["CROPTYPEID"] = e.CommandArgument;
                int         CropEditID = Convert.ToInt32(ViewState["CROPTYPEID"]);
                GridViewRow row        = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;
                if (row != null)
                {
                    txtCropType.Text = row.Cells[1].Text.ToString();
                    //ddlUnitOfmeasure.SelectedItem.Text = row.Cells[2].Text.ToString();
                }

                GetCropTypeDeatails();
                SetUpdateMode(true);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Added", "setDirty();", true);
            }
            else if (e.CommandName == "DeleteRow")
            {
                CropTypeBLL CropTypeBLLObj = new CropTypeBLL();
                string      message        = string.Empty;

                try
                {
                    message = CropTypeBLLObj.DeleteCropTypeRow(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);
                    }
                    ClearCropType();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                SetUpdateMode(false);
                BindGrid();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// To fetch details and assign to textbox
        /// </summary>
        private void GetCropTypeDeatails()
        {
            CropTypeBO CropTypeBOObj = new CropTypeBO();

            int CROPTYPEID = 0;

            if (ViewState["CROPTYPEID"] != null)
            {
                CROPTYPEID = Convert.ToInt32(ViewState["CROPTYPEID"].ToString());
            }

            CropTypeBLL CropTypeBLLOBj = new CropTypeBLL();

            CropTypeBOObj = CropTypeBLLOBj.GetCropTypeById(CROPTYPEID);

            txtCropType.Text = CropTypeBOObj.CropType;

            //ddlUnitOfmeasure.ClearSelection();
            //if (ddlUnitOfmeasure.Items.FindByValue(CropTypeBOObj.UnitMeasure.ToString()) != null)
            //    ddlUnitOfmeasure.Items.FindByValue(CropTypeBOObj.UnitMeasure.ToString()).Selected = true;

            txtCropTypeID.Text = CropTypeBOObj.CROPTYPEID.ToString();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// To save details to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveCropTypeDetails(CropTypeBO CropTypeBOObj)
        {
            string message = "";

            if (txtCropTypeID.Text.ToString().Trim() == string.Empty)
            {
                try
                {
                    CropTypeBOObj = new CropTypeBO();
                    CropTypeBLL CropTypeBLLObj = new CropTypeBLL();

                    CropTypeBOObj.CropType   = txtCropType.Text.ToString().Trim();
                    CropTypeBOObj.CROPTYPEID = Convert.ToInt32(ViewState["CROPTYPEID"]);
                    //CropTypeBOObj.UnitMeasure= Convert.ToInt32(ddlUnitOfmeasure.SelectedValue);
                    CropTypeBOObj.Createdby = Convert.ToInt32(Session["USER_ID"].ToString());
                    message = CropTypeBLLObj.InsertCropTypeDetails(CropTypeBOObj);

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

                    BindGrid();
                    ClearCropType();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                try
                {
                    CropTypeBOObj = new CropTypeBO();
                    CropTypeBLL CropTypeBLLObj = new CropTypeBLL();

                    CropTypeBOObj.CropType = txtCropType.Text.ToString().Trim();
                    //CropTypeBOObj.UnitMeasure = Convert.ToInt32(ddlUnitOfmeasure.SelectedItem.Value);
                    int CROPTYPEID = Convert.ToInt32(ViewState["CROPTYPEID"]);
                    CropTypeBOObj.Createdby = Convert.ToInt32(Session["USER_ID"].ToString());
                    message = CropTypeBLLObj.EditCropTypeDetails(CropTypeBOObj, CROPTYPEID);

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

                    BindGrid();
                    ClearCropType();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                finally
                {
                    CropTypeBOObj = null;
                }

                SetUpdateMode(false);
            }

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