Пример #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtTransferDate.Text == "")
        {
            DisplayMessage("Select Date");
            txtTransferDate.Text = DateTime.Now.ToString(ObjSysParam.GetSysParameterByParamName("Date_Format").Rows[0]["Param_Value"].ToString());

            txtTransferDate.Focus();
            return;
        }
        if (txtVoucherNo.Text == "")
        {
            DisplayMessage("Enter Voucher No.");
            txtVoucherNo.Focus();
            return;
        }
        string    LocationId = string.Empty;
        DataTable Dtlocation = objLocation.GetLocationMasterByLocationName(strCompId, txtLocationName.Text);

        if (Dtlocation.Rows.Count != 0)
        {
            LocationId = Dtlocation.Rows[0]["Location_Id"].ToString();
        }
        else
        {
            LocationId = "0";
        }



        bool b = false;

        string StrReqId = ViewState["RequestId"].ToString();

        if (editid.Value == "")
        {
            foreach (GridViewRow Row in GvProduct.Rows)
            {
                if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "")
                {
                    if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "0")
                    {
                        b = true;
                    }
                }
            }
            if (!b)
            {
                DisplayMessage("Enter Product Quantity");
                GvProduct.Focus();
                return;
            }


            ObjTransferHeader.InsertTransferHeader(strCompId, StrBrandId, StrLocId, txtTransferDate.Text.Trim(), StrReqId.Trim(), LocationId.Trim(), txtDescription.Text.Trim(), "N", DateTime.Now.ToString(), null, txtVoucherNo.Text.Trim(), "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), UserId.ToString(), DateTime.Now.ToString(), UserId.ToString(), DateTime.Now.ToString());

            string TransId = ObjTransferHeader.getAutoId();
            foreach (GridViewRow Row in GvProduct.Rows)
            {
                if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "")
                {
                    if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "0")
                    {
                        ObjTransferDetail.InsertTransferDetail(strCompId, StrBrandId, StrLocId, TransId, ((Label)Row.FindControl("lblSerialNO")).Text.Trim(), ((Label)Row.FindControl("lblPId")).Text.Trim(), ((Label)Row.FindControl("lblunitcost")).Text.Trim(), ((Label)Row.FindControl("lblUnitId")).Text.Trim(), ((Label)Row.FindControl("lblReqQty")).Text.Trim(), ((TextBox)Row.FindControl("txtOutQty")).Text.Trim(), "0", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), UserId.ToString(), DateTime.Now.ToString(), UserId.ToString(), DateTime.Now.ToString());
                    }
                }
            }
            DisplayMessage("Record Saved");
            int insertintransReq = 0;
            insertintransReq = ObjTransReq.UpdateStatusInTransferRequestHeader(StrReqId, strCompId, StrBrandId, LocationId.Trim(), UserId.ToString(), DateTime.Now.ToString(), "2");
        }
        else
        {
            foreach (GridViewRow Row in gvEditProduct.Rows)
            {
                if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "")
                {
                    if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "0")
                    {
                        b = true;
                    }
                }
            }
            if (!b)
            {
                DisplayMessage("Enter Product Quantity");
                GvProduct.Focus();
                return;
            }
            ObjTransferHeader.UpdateTransferHeader(editid.Value, strCompId, StrBrandId, StrLocId, txtTransferDate.Text.Trim(), StrReqId.Trim(), LocationId.Trim(), txtDescription.Text.Trim(), "N", DateTime.Now.ToString(), null, txtVoucherNo.Text.Trim(), "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), UserId.ToString(), DateTime.Now.ToString(), UserId.ToString(), DateTime.Now.ToString());
            ObjTransferDetail.DeleteTransferDetailbyHeaderTransId(strCompId, StrBrandId, StrLocId, editid.Value);
            string TransId = editid.Value;
            foreach (GridViewRow Row in gvEditProduct.Rows)
            {
                if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "")
                {
                    if (((TextBox)Row.FindControl("txtOutQty")).Text.Trim() != "0")
                    {
                        ObjTransferDetail.InsertTransferDetail(strCompId, StrBrandId, StrLocId, TransId, ((Label)Row.FindControl("lblSerialNO")).Text.Trim(), ((Label)Row.FindControl("lblPId")).Text.Trim(), ((Label)Row.FindControl("lblunitcost")).Text.Trim(), ((Label)Row.FindControl("lblUnitId")).Text.Trim(), ((Label)Row.FindControl("lblReqQty")).Text.Trim(), ((TextBox)Row.FindControl("txtOutQty")).Text.Trim(), "0", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), UserId.ToString(), DateTime.Now.ToString(), UserId.ToString(), DateTime.Now.ToString());
                    }
                }
            }
            DisplayMessage("Record Update");
        }


        Reset();
        ViewState["RequestId"] = null;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtlRequestNo.Text == "")
        {
            ViewState["Return"] = 1;
            DisplayMessage("Enter Request No.");
            txtlRequestNo.Focus();
            return;
        }
        if (txtLocationName.Text == "")
        {
            ViewState["Return"] = 1;
            DisplayMessage("Enter Location Name");
            txtLocationName.Focus();
            return;
        }
        if (gvProductRequest.Rows.Count == 0)
        {
            ViewState["Return"] = 1;
            DisplayMessage("Enter Product Details");
            btnAddProduct.Focus();
            return;
        }
        if (txtTermCondition.Text == "")
        {
            ViewState["Return"] = 1;
            DisplayMessage("Enter Discription");

            txtTermCondition.Focus();
            return;
        }
        if (txtLocationName.Text == "")
        {
            DisplayMessage("Enter Location Name");
            txtLocationName.Focus();
            return;
        }
        string post = string.Empty;

        if (ChkPost.Checked == true)
        {
            post = "Y";
        }
        else
        {
            post = "N";
        }
        string    LocationId = string.Empty;
        DataTable Dtlocation = objLocation.GetLocationMasterByLocationName(StrCompId, txtLocationName.Text);

        if (Dtlocation.Rows.Count == 0)
        {
            DisplayMessage("Invalid Location");
            txtLocationName.Focus();
            return;
        }
        else
        {
            LocationId = Dtlocation.Rows[0]["Location_Id"].ToString();
        }


        int b = 0;

        if (editid.Value == "")
        {
            b = ObjTrans.InsertTransferRequestHeader(StrCompId.ToString(), StrBrandId.ToString(), StrLocationId.ToString(), txtlRequestNo.Text, txtRequestdate.Text, txtTermCondition.Text, post, "0", LocationId.ToString(), false.ToString(), false.ToString(), "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), UserId.ToString(), DateTime.Now.ToString(), UserId.ToString(), DateTime.Now.ToString());

            if (b != 0)
            {
                DisplayMessage("Record Saved");
            }
        }
        else
        {
            b = ObjTrans.UpdateTransferRequestHeader(editid.Value, StrCompId.ToString(), StrBrandId.ToString(), StrLocationId.ToString(), txtlRequestNo.Text, txtRequestdate.Text, txtTermCondition.Text, post, "0", LocationId.ToString(), "", false.ToString(), "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), UserId.ToString(), DateTime.Now.ToString(), UserId.ToString(), DateTime.Now.ToString());

            if (b != 0)
            {
                DisplayMessage("Record Update");
                btnList_Click(null, null);
            }
        }
        ViewState["RequestNo"] = txtlRequestNo.Text;



        Fillgrid();
        Reset();
    }