Exemplo n.º 1
0
        /// <summary>
        /// Saves a record to the M_CNReason table.
        /// </summary>
        public Boolean Savem_CNReasonSP(M_CNReason m_CNReason, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

            try
            {
                scom             = new SqlCommand();
                scom.CommandType = CommandType.StoredProcedure;
                scom.CommandText = "M_CNReasonSave";

                scom.Parameters.Add("@ID", SqlDbType.VarChar, 20).Value           = m_CNReason.ID;
                scom.Parameters.Add("@Reason", SqlDbType.VarChar, 40).Value       = m_CNReason.Reason;
                scom.Parameters.Add("@NeedToUpdateStock", SqlDbType.Bit, 1).Value = m_CNReason.NeedToUpdateStock;
                scom.Parameters.Add("@StockType", SqlDbType.VarChar, 10).Value    = m_CNReason.StockType;
                scom.Parameters.Add("@UserCode", SqlDbType.VarChar, 20).Value     = m_CNReason.UserCode;
                scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value        = m_CNReason.Datex;
                scom.Parameters.Add("@InsMode", SqlDbType.Int).Value  = formMode; // For insert
                scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0;

                u_DBConnection dbcon = new u_DBConnection();
                retvalue = dbcon.RunQuery(scom);
                return(retvalue);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 2
0
        public List <M_CNReason> SelectM_CNReasonMulti(M_CNReason objm_CNReason2)
        {
            List <M_CNReason> retval = new List <M_CNReason>();

            try
            {
                strquery = @"select * from M_CNReason where ID = '" + objm_CNReason2.ID + "'";
                DataTable dtm_CNReason = u_DBConnection.ReturnDataTable(strquery, CommandType.Text);
                foreach (DataRow drType in dtm_CNReason.Rows)
                {
                    if (drType != null)
                    {
                        M_CNReason objm_CNReason = new M_CNReason();
                        objm_CNReason.ID                = drType["ID"].ToString();
                        objm_CNReason.Reason            = drType["Reason"].ToString();
                        objm_CNReason.NeedToUpdateStock = bool.Parse(drType["NeedToUpdateStock"].ToString());
                        objm_CNReason.StockType         = drType["StockType"].ToString();
                        objm_CNReason.UserCode          = drType["UserCode"].ToString();
                        objm_CNReason.Datex             = DateTime.Parse(drType["Datex"].ToString());
                        retval.Add(objm_CNReason);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public static string FindExisitingCNReason(string suppcode)
        {
            string str = "";

            if (M_CNReasonDL.ExistingM_CNReason(suppcode.Trim()))
            {
                M_CNReason cat = new M_CNReason();
                cat.ID = suppcode.Trim();
                str    = new M_CNReasonDL().Selectm_CNReason(cat).Reason;
            }
            else
            {
                str = "<Error!!!>";
            }
            return(str);
        }
Exemplo n.º 4
0
 public M_CNReason Selectm_CNReason(M_CNReason objm_CNReason)
 {
     try
     {
         strquery = @"select * from M_CNReason where ID = '" + objm_CNReason.ID + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objm_CNReason.ID                = drType["ID"].ToString();
             objm_CNReason.Reason            = drType["Reason"].ToString();
             objm_CNReason.NeedToUpdateStock = bool.Parse(drType["NeedToUpdateStock"].ToString());
             objm_CNReason.StockType         = drType["StockType"].ToString();
             objm_CNReason.UserCode          = drType["UserCode"].ToString();
             objm_CNReason.Datex             = DateTime.Parse(drType["Datex"].ToString());
             return(objm_CNReason);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 private void SetValues(String sm_Area)
 {
     try
     {
         M_CNReason objm_CNReason = new M_CNReason();
         if (sm_Area != "")
         {
             objm_CNReason.ID = sm_Area;
             objm_CNReason    = new M_CNReasonDL().Selectm_CNReason(objm_CNReason);
             if (objm_CNReason != null)
             {
                 txt_ID.Text     = objm_CNReason.ID.ToString();
                 txt_Reason.Text = objm_CNReason.Reason.ToString();
                 Chk_NeedToUpdateStock.Checked = objm_CNReason.NeedToUpdateStock.Value;
                 comboBox1.Text = objm_CNReason.StockType.ToString();
                 formMode       = 3;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
        private void performButtons(xEnums.PerformanceType xenum)
        {
            switch (xenum)
            {
            case xEnums.PerformanceType.View:

                if (ActiveControl.Name.Trim() == txt_ID.Name.Trim())
                {
                    int      length         = Convert.ToInt32(ConfigurationManager.AppSettings["AreaFieldLength"]);
                    string[] strSearchField = new string[length];

                    string strSQL = ConfigurationManager.AppSettings["AreaSQL"].ToString();

                    for (int i = 0; i < length; i++)
                    {
                        string m;
                        m = i.ToString();
                        strSearchField[i] = ConfigurationManager.AppSettings["AreaField" + m + ""].ToString();
                    }

                    frmU_Search find = new frmU_Search(strSQL, strSearchField, this);
                    find.ShowDialog(this);
                }

                break;

            case xEnums.PerformanceType.New:
                FunctionButtonStatus(xEnums.PerformanceType.New);
                formMode = 1;
                txt_ID.Focus();
                errorProvider1.Clear();
                break;

            case xEnums.PerformanceType.Edit:
                FunctionButtonStatus(xEnums.PerformanceType.Edit);
                formMode       = 3;
                txt_ID.Enabled = false;
                txt_Reason.Focus();
                errorProvider1.Clear();
                break;

            case xEnums.PerformanceType.Save:
                try
                {
                    if (txt_ID.Text.Trim() == "")
                    {
                        errorProvider1.SetError(txt_ID, "Please enter a credit note code !");
                        return;
                    }

                    if (txt_Reason.Text.Trim() == "")
                    {
                        errorProvider1.SetError(txt_Reason, "Please enter a subcategory name !");
                        return;
                    }
                    if (formMode == 1)
                    {
                        if (M_CNReasonDL.ExistingM_CNReason(txt_ID.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_ID, "The credit note reason you have entered already exists!");
                            return;
                        }

                        if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                        {
                            M_CNReason objm_CNReason = new M_CNReason();
                            objm_CNReason.ID                = txt_ID.Text.Trim();
                            objm_CNReason.Reason            = txt_Reason.Text.Trim();
                            objm_CNReason.NeedToUpdateStock = Chk_NeedToUpdateStock.Checked;
                            objm_CNReason.StockType         = comboBox1.Text.Trim();
                            objm_CNReason.UserCode          = commonFunctions.Loginuser;
                            objm_CNReason.Datex             = DateTime.Now;
                            new M_CNReasonDL().Savem_CNReasonSP(objm_CNReason, 1);



                            GetData();

                            txt_ID.Enabled = true;
                            FunctionButtonStatus(xEnums.PerformanceType.Save);
                            commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2);
                        }
                    }
                    else if (formMode == 3)
                    {
                        if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                        {
                            M_CNReason objm_CNReason = new M_CNReason();
                            objm_CNReason.ID                = txt_ID.Text.Trim();
                            objm_CNReason.Reason            = txt_Reason.Text.Trim();
                            objm_CNReason.NeedToUpdateStock = Chk_NeedToUpdateStock.Checked;
                            objm_CNReason.StockType         = comboBox1.Text.Trim();
                            objm_CNReason.UserCode          = commonFunctions.Loginuser;
                            objm_CNReason.Datex             = DateTime.Now;
                            new M_CNReasonDL().Savem_CNReasonSP(objm_CNReason, 3);

                            GetData();
                            txt_ID.Enabled = true;
                            FunctionButtonStatus(xEnums.PerformanceType.Save);

                            commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                    commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1);
                }

                break;

            case xEnums.PerformanceType.Cancel:
                txt_ID.Enabled = true;
                FunctionButtonStatus(xEnums.PerformanceType.Default);
                errorProvider1.Clear();
                break;

            case xEnums.PerformanceType.Print:
                UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information);
                break;
            }
        }