Пример #1
0
        public static List <ATTBenchType> GetBenchType(int?BenchTypeID, string active, int defaultFlag)
        {
            List <ATTBenchType> BenchTypeLST = new List <ATTBenchType>();

            try
            {
                foreach (DataRow row in DLLBenchType.GetBenchType(BenchTypeID, active).Rows)
                {
                    ATTBenchType objBenchType = new ATTBenchType();
                    objBenchType.BenchTypeID   = int.Parse(row["BENCH_TYPE_ID"].ToString());
                    objBenchType.BenchTypeName = row["BENCH_TYPE_NAME"].ToString();
                    objBenchType.Active        = row["ACTIVE"].ToString();
                    BenchTypeLST.Add(objBenchType);
                }

                if (defaultFlag > 0)
                {
                    ATTBenchType obj = new ATTBenchType();
                    obj.BenchTypeID   = 0;
                    obj.BenchTypeName = "छान्नुहोस";
                    BenchTypeLST.Insert(0, obj);
                }
                return(BenchTypeLST);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 public static bool SaveBenchType(ATTBenchType objBenchType)
 {
     try
     {
         return(DLLBenchType.SaveBenchType(objBenchType));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static bool SaveBenchType(ATTBenchType objBenchType)
        {
            string InsertUpdateSQL = "";

            List <OracleParameter> paramArray = new List <OracleParameter>();
            GetConnection          GetConn    = new GetConnection();
            OracleTransaction      Tran       = GetConn.GetDbConn(Module.CMS).BeginTransaction();

            try
            {
                paramArray.Add(Utilities.GetOraParam(":P_BENCH_TYPE_ID", objBenchType.BenchTypeID, OracleDbType.Int64, ParameterDirection.InputOutput));
                paramArray.Add(Utilities.GetOraParam(":P_BENCH_TYPE_NAME", objBenchType.BenchTypeName, OracleDbType.Varchar2, ParameterDirection.Input));
                paramArray.Add(Utilities.GetOraParam(":P_ACTIVE", objBenchType.Active, OracleDbType.Varchar2, ParameterDirection.Input));
                paramArray.Add(Utilities.GetOraParam(":P_ENTRY_BY", objBenchType.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input));

                if (objBenchType.Action == "A")
                {
                    InsertUpdateSQL = "SP_ADD_BENCH_TYPE";
                }
                else if (objBenchType.Action == "E")
                {
                    InsertUpdateSQL = "SP_EDIT_BENCH_TYPE";
                }

                SqlHelper.ExecuteNonQuery(Tran, System.Data.CommandType.StoredProcedure, InsertUpdateSQL, paramArray.ToArray());
                objBenchType.BenchTypeID = int.Parse(paramArray[0].Value.ToString());
                objBenchType.Action      = "";



                Tran.Commit();
                return(true);
            }
            catch (OracleException oex)
            {
                PCS.COREDL.OracleError oe = new PCS.COREDL.OracleError();
                throw new ArgumentException(oe.GetOraError(oex.Number, oex.Message));
            }

            catch (Exception ex)
            {
                Tran.Rollback();
                throw ex;
            }
            finally
            {
                GetConn.CloseDbConn();
            }
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.txtBenchType.Text == "")
        {
            this.lblStatusMessage.Text = "Bench Type Can't Be Left Blank";
            this.programmaticModalPopup.Show();
            return;
        }



        List <ATTBenchType> BenchTypeLST = (List <ATTBenchType>)Session["BenchType"];

        int i = -1;

        if (this.lstBenchType.SelectedIndex > -1)
        {
            i = BenchTypeLST.FindIndex(delegate(ATTBenchType obj)
            {
                return(this.txtBenchType.Text.ToUpper() == obj.BenchTypeName.ToUpper() && this.lstBenchType.SelectedItem.Text.ToUpper() != this.txtBenchType.Text.ToUpper());
            });
        }
        else
        {
            i = BenchTypeLST.FindIndex(delegate(ATTBenchType obj)
            {
                return(this.txtBenchType.Text.ToUpper() == obj.BenchTypeName.ToUpper());
            });
        }
        if (i > -1)
        {
            this.lblStatusMessage.Text = "Bench Type Name Already Exists";
            this.programmaticModalPopup.Show();
            return;
        }


        ATTBenchType objBenchType = new ATTBenchType();

        objBenchType.BenchTypeID   = (this.lstBenchType.SelectedIndex == -1) ? 0 : int.Parse(this.lstBenchType.SelectedValue);
        objBenchType.BenchTypeName = this.txtBenchType.Text;
        objBenchType.Active        = (chkBenchTypeActive.Checked == true) ? "Y" : "N";
        objBenchType.EntryBy       = "manoz";
        objBenchType.Action        = (this.lstBenchType.SelectedIndex == -1) ? "A" : "E";

        try
        {
            if (BLLBenchType.SaveBenchType(objBenchType) == true)
            {
                if (this.lstBenchType.SelectedIndex == -1)
                {
                    BenchTypeLST.Add(objBenchType);
                }
                else
                {
                    BenchTypeLST.RemoveAt(this.lstBenchType.SelectedIndex);
                    BenchTypeLST.Add(objBenchType);
                }

                lstBenchType.DataSource     = BenchTypeLST;
                lstBenchType.DataValueField = "BenchTypeID";
                lstBenchType.DataTextField  = "BenchTypeName";
                lstBenchType.DataBind();

                clearAll();
            }
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = "Bench Type Couldn't Be Saved<BR>" + ex.Message;
            this.programmaticModalPopup.Show();
        }
    }