Esempio n. 1
0
        /// <summary>
        /// To Update details of Cuircuit in Program table
        /// Created By : Chintan, 06-10-2015
        /// Modified By :
        /// </summary>
        public ApplicationResult Program_Update(ProgramBo objCuircuitBo)
        {
            try
            {
                pSqlParameter = new SqlParameter[5];


                pSqlParameter[0]           = new SqlParameter("@Id", SqlDbType.Int);
                pSqlParameter[0].Direction = ParameterDirection.Input;
                pSqlParameter[0].Value     = objCuircuitBo.Id;

                pSqlParameter[1]           = new SqlParameter("@Name", SqlDbType.NVarChar);
                pSqlParameter[1].Direction = ParameterDirection.Input;
                pSqlParameter[1].Value     = objCuircuitBo.Name;

                pSqlParameter[2]           = new SqlParameter("@PLCValue", SqlDbType.Real);
                pSqlParameter[2].Direction = ParameterDirection.Input;
                pSqlParameter[2].Value     = objCuircuitBo.PLCValue;

                pSqlParameter[3]           = new SqlParameter("@LastModifiedBy", SqlDbType.Int);
                pSqlParameter[3].Direction = ParameterDirection.Input;
                pSqlParameter[3].Value     = objCuircuitBo.LastModifiedBy;

                pSqlParameter[4]           = new SqlParameter("@LastModifiedDate", SqlDbType.DateTime);
                pSqlParameter[4].Direction = ParameterDirection.Input;
                pSqlParameter[4].Value     = objCuircuitBo.LastModifiedDate;

                sSql = "usp_tbl_Program_Update";

                //int iResult = Database.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter);

                //if (iResult > 0)
                //{
                //    ApplicationResult objResults = new ApplicationResult();
                //    objResults.Status = ApplicationResult.CommonStatusType.Success;
                //    return objResults;
                //}
                //else
                //{
                //    ApplicationResult objResults = new ApplicationResult();
                //    objResults.Status = ApplicationResult.CommonStatusType.Failure;
                //    return objResults;
                //}
                DataTable dtResult = new DataTable();
                dtResult = Database.ExecuteDataTable(CommandType.StoredProcedure, sSql, pSqlParameter);
                ApplicationResult objResults = new ApplicationResult(dtResult);
                objResults.Status = ApplicationResult.CommonStatusType.Success;
                return(objResults);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objCuircuitBo = null;
            }
        }
Esempio n. 2
0
 protected void btnSave_OnClick(object sender, EventArgs e)
 {
     try
     {
         ProgramBo objProgramBo = new ProgramBo();
         ProgramBl objProgramBl = new ProgramBl();
         objProgramBo.Name     = txtName.Text.Trim();
         objProgramBo.PLCValue = Convert.ToInt32(txtPLCValue.Text);
         if (ViewState["Mode"].ToString() == "Save")
         {
             objProgramBo.CreatedBy   = Convert.ToInt32(Session[ApplicationSession.Userid]);
             objProgramBo.CreatedDate = DateTime.UtcNow.AddHours(5.5);
             var objResult = objProgramBl.Program_Insert(objProgramBo);
             if (objResult != null)
             {
                 if (objResult.ResultDt.Rows.Count > 0)
                 {
                     int intStatus = Convert.ToInt32(objResult.ResultDt.Rows[0]["Status"].ToString());
                     if (intStatus == 0)
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('" + txtName.Text + " is already exist.');</script>");
                     }
                     else
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Saved Successfully.');</script>");
                         ClearAll();
                         BindgvProgram();
                         PanelVisibilityMode(true, false);
                     }
                 }
             }
         }
         else if (ViewState["Mode"].ToString() == "Edit")
         {
             objProgramBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.Userid]);
             objProgramBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5);
             objProgramBo.Id = Convert.ToInt32(ViewState["ID"].ToString());
             var objResult = objProgramBl.Program_Update(objProgramBo);
             if (objResult != null)
             {
                 if (objResult.ResultDt.Rows.Count > 0)
                 {
                     int intStatus = Convert.ToInt32(objResult.ResultDt.Rows[0]["Status"].ToString());
                     if (intStatus == 0)
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('" + txtName.Text + " is already exist.');</script>");
                     }
                     else
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Updated Successfully.');</script>");
                         ClearAll();
                         BindgvProgram();
                         PanelVisibilityMode(true, false);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("Error", ex);
         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
     }
 }