예제 #1
0
        protected void ddlSubGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (ddlSubGroup.SelectedValue != "-Select-" && ddlGroup.SelectedValue != "-Select-")
                {
                    A2ZSUBGROUPDTO getDTO   = new A2ZSUBGROUPDTO();
                    int            code     = Converter.GetInteger(ddlGroup.SelectedValue);
                    int            distcode = Converter.GetInteger(ddlSubGroup.SelectedValue);
                    getDTO = (A2ZSUBGROUPDTO.GetInformation(code, distcode));

                    if (getDTO.GrpCode > 0 && getDTO.SubGrpCode > 0)
                    {
                        hdnSubGrpCode.Text = Converter.GetString(getDTO.SubGrpCode);

                        txtSubGrpDescription.Text = Converter.GetString(getDTO.SubGrpDescription);
                        txtSubGrpDescription.Focus();
                        BtnSubmit.Visible = false;
                        BtnUpdate.Visible = true;
                    }
                }
                else
                {
                    BtnUpdate.Visible = false;
                    BtnSubmit.Visible = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (ddlGroup.SelectedValue != "-Select-" && ddlItemType.SelectedValue != "-Select-")
            {
                int            LR         = 0;
                int            GrpCode    = Converter.GetInteger(ddlGroup.SelectedValue);
                int            SubGrpCode = Converter.GetInteger(ddlItemType.SelectedValue);
                A2ZSUBGROUPDTO getDTO     = (A2ZSUBGROUPDTO.GetInformation(GrpCode, SubGrpCode));
                if (getDTO.LastRec >= 0)
                {
                    LR  = Converter.GetInteger(getDTO.LastRec);
                    LR += 1;
                    hdnNewSTKNo.Text = SubGrpCode.ToString("0") + GrpCode.ToString("00") + LR.ToString("0000");
                }

                A2ZSTOCKDTO objDTO = new A2ZSTOCKDTO();
                objDTO.STKItemCode     = Converter.GetInteger(hdnNewSTKNo.Text);
                objDTO.STKItemName     = Converter.GetString(txtItemDesc.Text);
                objDTO.STKUnit         = Converter.GetInteger(ddlUnitMeasure.SelectedValue);
                objDTO.STKGroup        = Converter.GetInteger(ddlGroup.SelectedValue);
                objDTO.STKSubGroup     = Converter.GetInteger(ddlItemType.SelectedValue);
                objDTO.STKStatus       = 1;
                objDTO.STKStatusDesc   = "Active";
                objDTO.STKReOrderLevel = Converter.GetInteger(txtReorderLvl.Text);

                A2ZCSPARAMETERDTO dto = A2ZCSPARAMETERDTO.GetParameterValue();
                objDTO.STKStatusDate = Converter.GetDateTime(dto.ProcessDate.ToLongDateString());

                int roweffect = A2ZSTOCKDTO.InsertInformation(objDTO);
                if (roweffect > 0)
                {
                    A2ZSUBGROUPDTO SubGrpDTO = new A2ZSUBGROUPDTO();
                    SubGrpDTO.GrpCode    = GrpCode;
                    SubGrpDTO.SubGrpCode = SubGrpCode;
                    SubGrpDTO.LastRec    = LR;
                    int roweffect1 = A2ZSUBGROUPDTO.UpdateLastRec(SubGrpDTO);
                    if (roweffect1 > 0)
                    {
                        Response.Redirect(Request.RawUrl);
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Select Group and Sub Group');", true);
                return;
            }
        }