Exemplo n.º 1
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                decimal?insComId = null;
                decimal idTmp    = 0;
                if (decimal.TryParse(cmbInsNameSearch.SelectedValue, out idTmp))
                {
                    if (idTmp > 0)
                    {
                        insComId = idTmp;
                    }
                }

                List <ReceiveNoData> result = ObtScr002Biz.GetSearchData(cmbProductSearch.SelectedValue, insComId, false);
                // select only first item of result
                result = result.GroupBy(r => new { r.InsComId, r.CodeName })
                         .Select(g => g.OrderByDescending(r => r.Lot).FirstOrDefault())
                         .ToList();

                BindGridview(pcTop, gvResult, result.ToArray(), 0);
                pcTop.Visible    = true;
                gvResult.Visible = true;
                upResult.Update();
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 2
0
        protected void radioActive_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                string alertMessage = "";
                bool   inuse        = ObtScr002Biz.HasLotInUse(hiddenProductId.Value, SLMUtil.SafeDecimal(hiddenInsComId.Value));
                if (inuse)
                {
                    alertMessage           = "มี Lot ที่ใช้งานอยู่แล้ว ไม่สามารถเปลี่ยนสถานะได้";
                    trConfirmOK.Visible    = true;
                    trComfirmYesNo.Visible = false;
                }
                else
                {
                    alertMessage           = "ต้องการเปลี่ยนสถานะใช่หรือไม่?";
                    trConfirmOK.Visible    = false;
                    trComfirmYesNo.Visible = true;
                }

                GridViewRow row = ((RadioButton)sender).Parent.Parent as GridViewRow;
                txtEditRowIndex.Text = row.RowIndex.ToString();
                lblAlertMessage.Text = alertMessage;
                upConfirm.Update();
                mpePopupConfirm.Show();
                mpePopupEdit.Show();
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 3
0
        protected void btnConfirmYes_Click(object sender, EventArgs e)
        {
            try
            {
                int         gridviewRowIndex  = Convert.ToInt32(txtEditRowIndex.Text.Trim());
                RadioButton radioActive       = gvReceiveNoList.Rows[gridviewRowIndex].FindControl("radioActive") as RadioButton;
                RadioButton radioDeactive     = gvReceiveNoList.Rows[gridviewRowIndex].FindControl("radioDeactive") as RadioButton;
                HiddenField hiddenReceiveNoId = gvReceiveNoList.Rows[gridviewRowIndex].FindControl("hiddenReceiveNoId") as HiddenField;

                if (string.IsNullOrEmpty(hiddenReceiveNoId.Value))
                {
                    mpePopupConfirm.Hide();
                    RollbackRadioButton(Convert.ToInt32(txtEditRowIndex.Text.Trim()));
                    AppUtil.ClientAlert(Page, "ไม่พบข้อมูลเลขที่รับแจ้งในระบบ");
                }
                else
                {
                    ObtScr002Biz.UpdateDeleleFlag(decimal.Parse(hiddenReceiveNoId.Value), radioDeactive.Checked, HttpContext.Current.User.Identity.Name);
                    mpePopupConfirm.Hide();
                    mpePopupEdit.Show();
                }
            }
            catch (Exception ex)
            {
                mpePopupConfirm.Hide();
                RollbackRadioButton(Convert.ToInt32(txtEditRowIndex.Text.Trim()));

                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 4
0
        protected void imbEdit_Click(object sender, EventArgs e)
        {
            try
            {
                string[] args = ((ImageButton)sender).CommandArgument.Split(',');
                if (args.Length < 2)
                {
                    return;
                }

                string  productid = args[1];
                decimal insComId  = 0;
                if (decimal.TryParse(args[0], out insComId))
                {
                    var result = ObtScr002Biz.GetSearchData(productid, insComId, true);
                    textInsName.Text      = result[0].InsComName;
                    hiddenInsComId.Value  = insComId.ToString();
                    textProductName.Text  = result[0].ProductName;
                    hiddenProductId.Value = productid;
                    result = result.Where(r => r.ReceiveNoId != -1).OrderBy(r => r.IsDeleted == true ? 1 : 0).ThenByDescending(r => r.UpdatedDate).ToList();

                    BindGridview(pcReceiveNo, gvReceiveNoList, result.ToArray(), 0);
                    upnPopupEdit.Update();
                    mpePopupEdit.Show();
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 5
0
        protected void pcReceiveNo_PageSearchChange(object sender, EventArgs e)
        {
            try
            {
                string  productid = hiddenProductId.Value;
                decimal insComId  = 0;
                if (decimal.TryParse(hiddenInsComId.Value, out insComId))
                {
                    var result = ObtScr002Biz.GetSearchData(productid, insComId, true);
                    textInsName.Text      = result[0].InsComName;
                    hiddenInsComId.Value  = insComId.ToString();
                    textProductName.Text  = result[0].ProductName;
                    hiddenProductId.Value = productid;
                    result = result.Where(r => r.ReceiveNoId != -1).OrderBy(r => r.IsDeleted == true ? 1 : 0).ThenByDescending(r => r.UpdatedDate).ToList();

                    BindGridview(pcReceiveNo, gvReceiveNoList, result.ToArray(), pcReceiveNo.SelectedPageIndex);
                    upnPopupEdit.Update();
                    mpePopupEdit.Show();
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 6
0
        protected void PageSearchChange(object sender, EventArgs e)
        {
            try
            {
                List <ReceiveNoData> result = ObtScr002Biz.GetSearchData(cmbProductSearch.SelectedValue, null, false);
                // select only first item of result
                result = result.GroupBy(r => new { r.InsComId, r.CodeName })
                         .Select(g => g.OrderByDescending(r => r.Lot).FirstOrDefault())
                         .ToList();

                if (result != null && result.Count > 0)
                {
                    BindGridview(pcTop, gvResult, result.ToArray(), pcTop.SelectedPageIndex);
                }
                else
                {
                    BindGridview(pcTop, gvResult, null, 0);
                }

                upResult.Update();
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 7
0
        protected void btnPopupDoImportExcel_Click(object sender, EventArgs e)
        {
            try
            {
                string        message = "";
                ReceiveNoData data    = new ReceiveNoData();
                data.CodeName        = textCodeName.Text;
                data.InsComId        = SLMUtil.SafeDecimal(hiddenInsComId.Value);
                data.IsDeleted       = false;
                data.ProductId       = hiddenProductId.Value;
                data.ReceiveNoCancel = 0;
                data.ReceiveNoEnd    = SLMUtil.SafeDecimal(textEndReceiveNoNumber.Text);
                data.ReceiveNoStart  = SLMUtil.SafeDecimal(textStartReceiveNoNumber.Text);
                data.ReceiveNoRemain = data.ReceiveNoEnd - data.ReceiveNoStart;
                data.ReceiveNoTotal  = data.ReceiveNoRemain;
                data.ReceiveNoUsed   = 0;
                data.UpdatedBy       = HttpContext.Current.User.Identity.Name;
                data.UpdatedDate     = DateTime.Now;
                data.IsDeleted       = false;
                if (ObtScr002Biz.SaveReceiveData(data, out message))
                {
                    // rebind gridview
                    var result = ObtScr002Biz.GetSearchData(data.ProductId, data.InsComId, true);
                    BindGridview(pcReceiveNo, gvReceiveNoList, result.ToArray(), 0);

                    // hide add panel & clear data
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "hidePanel", "CancelAdd();", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "hidePanel", "AddReceiveNo();", true);
                }
                lblError.Text = message;
                mpePopupEdit.Show();
                mpePopupError.Show();
                upError.Update();
                //upnPopupEdit.Update();
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    ScreenPrivilegeData priData = RoleBiz.GetScreenPrivilege(HttpContext.Current.User.Identity.Name, "SLM_SCR_031");
                    if (priData == null || priData.IsView != 1)
                    {
                        AppUtil.ClientAlertAndRedirect(Page, "คุณไม่มีสิทธิ์เข้าใช้หน้าจอนี้", "SLM_SCR_003.aspx");
                        return;
                    }

                    ((Label)Page.Master.FindControl("lblTopic")).Text = "จัดการข้อมูลเลขรับแจ้ง";
//                    cmbProductSearch.DataSource = ProductBiz.GetProductList();
                    cmbProductSearch.DataSource = ProductBiz.GetProductListNew();
                    cmbProductSearch.DataBind();
                    cmbProductSearch.Items.Insert(0, new ListItem("", "-1"));
                    cmbInsNameSearch.DataSource = ObtScr002Biz.GetInsCom();
                    cmbInsNameSearch.DataBind();
                    cmbInsNameSearch.Items.Insert(0, new ListItem()
                    {
                        Value = "-1", Text = "ทั้งหมด"
                    });

                    AppUtil.SetNumbericCharacter(textStartReceiveNoNumber);
                    AppUtil.SetNumbericCharacter(textEndReceiveNoNumber);
                    AppUtil.SetNumbericCharacter(textTotalReceiveNoNumber);
                    textStartReceiveNoNumber.Attributes.Add("onblur", "CalcTotalReceiveNo();");
                    textEndReceiveNoNumber.Attributes.Add("onblur", "CalcTotalReceiveNo();");
                    Page.Form.DefaultButton = btnSearch.UniqueID;
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }