Exemplo n.º 1
0
        protected void btnModalSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Validate
                if (txtMItemTypeCode.Text == "")
                {
                    ShowMessageBox("กรุณาระบุ รหัส !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                if (txtMItemTypeName.Text == "")
                {
                    ShowMessageBox("กรุณาระบุ ชื่อกลุ่ม !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                MasItemType o = new MasItemType();
                if (hddMode.Value == "Add") // Add
                {
                    o = new MasItemType();
                    o.ItemTypeName = txtMItemTypeName.Text;
                    o.ItemTypeCode = txtMItemTypeCode.Text;
                    o.Active       = "Y";
                    o.CreatedBy    = GetUsername();
                    o.CreatedDate  = DateTime.Now;
                    using (BillingEntities cre = new BillingEntities())
                    {
                        cre.MasItemTypes.Add(o);
                        cre.SaveChanges();
                    };
                }
                else //Edit
                {
                    int objID = ToInt32(hddID.Value);
                    using (BillingEntities cre = new BillingEntities())
                    {
                        o = cre.MasItemTypes.FirstOrDefault(w => w.ItemTypeID.Equals(objID));
                        if (o != null)
                        {
                            o.ItemTypeName = txtMItemTypeName.Text;
                            o.ItemTypeCode = txtMItemTypeCode.Text;
                            o.UpdatedBy    = GetUsername();
                            o.UpdatedDate  = DateTime.Now;
                        }
                        cre.SaveChanges();
                    };
                }

                BindData();
                ShowMessageBox("บันทึกข้อมูลสำเร็จ.");
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
Exemplo n.º 2
0
        protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                ImageButton imb = (ImageButton)sender;
                if (imb != null)
                {
                    MasItemType obj   = new MasItemType();
                    int         objID = ToInt32(imb.CommandArgument);
                    using (BillingEntities cre = new BillingEntities())
                    {
                        obj = cre.MasItemTypes.FirstOrDefault(w => w.ItemTypeID.Equals(objID));
                        if (obj != null)
                        {
                            obj.Active      = "N";
                            obj.UpdatedBy   = GetUsername();
                            obj.UpdatedDate = DateTime.Now;
                        }

                        //cre.MasItemTypes.Remove(obj);
                        cre.SaveChanges();
                    };
                    BindData();
                }
                else
                {
                    SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
Exemplo n.º 3
0
        public List <MasItemType> GetSearchItemType()
        {
            List <MasItemType> lst = new List <MasItemType>();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                DataSet             ds    = conn.GetDataSet("GetSearchItemType", param);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    MasItemType o = new MasItemType();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        o              = new MasItemType();
                        o.ItemTypeID   = Convert.ToInt32(dr["ItemTypeID"].ToString());
                        o.ItemTypeCode = dr["ItemTypeCode"].ToString();
                        o.ItemTypeName = dr["ItemTypeName"].ToString();
                        o.Active       = dr["Active"].ToString();
                        lst.Add(o);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lst);
        }
Exemplo n.º 4
0
        protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                ImageButton imb = (ImageButton)sender;
                MasItemType obj = new MasItemType();
                if (imb != null)
                {
                    int objID = ToInt32(imb.CommandArgument);
                    using (BillingEntities cre = new BillingEntities())
                    {
                        obj = cre.MasItemTypes.FirstOrDefault(w => w.ItemTypeID.Equals(objID));
                    };

                    if (obj != null)
                    {
                        hddID.Value           = imb.CommandArgument;
                        txtMItemTypeCode.Text = obj.ItemTypeCode;
                        txtMItemTypeName.Text = obj.ItemTypeName;

                        ModalPopupExtender1.Show();
                        hddMode.Value = "Edit";
                    }
                    else
                    {
                        SendMailError("obj is null, objID = " + imb.CommandArgument, System.Reflection.MethodBase.GetCurrentMethod());
                    }
                }
                else
                {
                    SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }