コード例 #1
0
    protected void RepDetailsConfirm_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        {
            bool Auth = DCMaster.Get_DocumentNum_Authentication(Convert.ToInt32(txtDocno.Text), Convert.ToInt32(strFY));
            if (Auth)
            {
                MessageBox("Document no is not available");
                txtDocno.Focus();
            }
            else
            {
                //   DCConfirmQtyDetails _objDCConfirmQtyDetails = new DCConfirmQtyDetails();
                //    DCMaster _objDCMaster = new DCMaster();
                DCConfirmQtyDetails _objDCFT = new DCConfirmQtyDetails();
                // ActualInvoiceDetails _objactualinvoice = new ActualInvoiceDetails();
                Other_Z.ActualInvoice_Details.ActualInvoice_DetailsProp _objactualinvoice = new Other_Z.ActualInvoice_Details.ActualInvoice_DetailsProp();
                Other_Z.ActualInvoice_Details ObjBal = new Other_Z.ActualInvoice_Details();

                try
                {
                    #region ActulInvoice
                    Repeater objrep  = (Repeater)this.FindControl("RepDetailsConfirm");
                    GridView objgrid = (GridView)objrep.Items[e.Item.ItemIndex].FindControl("grdapproval");


                    foreach (GridViewRow row in objgrid.Rows)
                    {
                        _objactualinvoice.GanerateinvoiceId = Convert.ToInt32(((Label)row.FindControl("lblgenerateinvoiceid")).Text);
                        _objactualinvoice.DocumentNo        = Convert.ToInt32(txtDocno.Text);
                        _objactualinvoice.SubDocId          = Convert.ToDecimal(e.CommandArgument.ToString().Trim());
                        _objactualinvoice.BookCode          = ((Label)row.FindControl("lblbookC")).Text;
                        _objactualinvoice.BookName          = ((Label)row.FindControl("lblbookN")).Text;
                        _objactualinvoice.Standard          = ((Label)row.FindControl("lblStandard")).Text;
                        _objactualinvoice.Medium            = ((Label)row.FindControl("lblMedium")).Text;
                        _objactualinvoice.Rate     = Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text);
                        _objactualinvoice.Quantity = Convert.ToInt32(((TextBox)row.FindControl("lblqunty")).Text);
                        _objactualinvoice.Discount = Convert.ToDecimal(((TextBox)row.FindControl("txtdiscount")).Text);

                        _objactualinvoice.Amount = Convert.ToInt32(((Label)row.FindControl("lblAqty")).Text) * (Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) - (Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) * Convert.ToDecimal(((TextBox)row.FindControl("txtdiscount")).Text) / 100));
                        // _objactualinvoice.Amount = Convert.ToDecimal(((Label)row.FindControl("lblamt")).Text);
                        _objactualinvoice.Freight     = Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text);
                        _objactualinvoice.Tax         = Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                        _objactualinvoice.Transporter = (((TextBox)e.Item.FindControl("lbltransporter")).Text);
                        _objactualinvoice.LRNo        = (((TextBox)e.Item.FindControl("txtlrno")).Text);
                        //  _objactualinvoice.TotalAmount = Convert.ToDecimal(((Label)e.Item.FindControl("lbltotalAmtget")).Text);
                        // Finalamount = Convert.ToDecimal(((Label)row.FindControl("lblTotalAmt")).Text);
                        _objactualinvoice.TotalAmount       = Convert.ToDecimal(getTotalValues(objgrid).ToString()) + Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text) + Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                        _objactualinvoice.Bundles           = (((TextBox)e.Item.FindControl("txtbundles")).Text);
                        _objactualinvoice.CreatedBy         = Convert.ToString(Session["UserName"]);
                        _objactualinvoice.FinancialYearFrom = strFY;

                        _objactualinvoice.HSNCode = ((Label)row.FindControl("lblHsnCode")).Text;
                        _objactualinvoice.GSTPer  = Convert.ToDecimal(((Label)row.FindControl("lblGstPer")).Text);
                        _objactualinvoice.Typ     = e.CommandName == "GSTInvoice" ? "G" : "N";
                        _objactualinvoice.GSTAmt  = Convert.ToDecimal(_objactualinvoice.Amount * _objactualinvoice.GSTPer / 100);


                        TextBox txtIdate1  = ((TextBox)e.Item.FindControl("txtdateabc"));
                        TextBox txtLrdate1 = ((TextBox)e.Item.FindControl("txtlrdate"));
                        _objactualinvoice.IsActive  = true;
                        _objactualinvoice.IsDeleted = false;
                        string date1;
                        string lrdate;

                        if (txtIdate1.Text == "")
                        {
                            date1 = "1/1/2001";
                        }
                        else
                        {
                            date1 = txtIdate1.Text.Split('/')[1] + "/" + txtIdate1.Text.Split('/')[0] + "/" + txtIdate1.Text.Split('/')[2];
                        }
                        if (txtLrdate1.Text == "")
                        {
                            lrdate = "1/1/2001";
                        }
                        else
                        {
                            lrdate = txtLrdate1.Text.Split('/')[1] + "/" + txtLrdate1.Text.Split('/')[0] + "/" + txtLrdate1.Text.Split('/')[2];
                        }
                        _objactualinvoice.InvoiceDate = Convert.ToDateTime(date1);
                        _objactualinvoice.LRDate      = Convert.ToDateTime(lrdate);
                        _objactualinvoice.Remark1     = "";
                        _objactualinvoice.Remark2     = "";
                        _objactualinvoice.Remark3     = "";
                        // _objactualinvoice.SaveActual_InvoiceDetails(1);
                        ObjBal.SaveActualInvoiceDetails(_objactualinvoice);
                        // (TextBox)e.Item.FindControl("txtfrieght");
                    }

                    #endregion

                    #region InvoiceCreate
                    decimal subconfirmdoc = Convert.ToDecimal(e.CommandArgument.ToString().Trim());
                    // Save Freight and tax Details
                    frieght = Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text);
                    tax     = Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                    temp    = tamount + frieght + tax;
                    // totalamount = tamount;
                    _objDCFT.Auto_ID     = Convert.ToInt32(((Label)e.Item.FindControl("Lblautoid")).Text);
                    _objDCFT.DocumentNo  = Convert.ToInt32(txtDocno.Text);
                    _objDCFT.SubDocNo    = subconfirmdoc;
                    _objDCFT.Freight     = Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text);
                    _objDCFT.Tax         = Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                    _objDCFT.TotalAmount = Convert.ToDecimal(((Label)e.Item.FindControl("lblallTotalamt")).Text);
                    _objDCFT.LRNo        = (((TextBox)e.Item.FindControl("txtlrno")).Text);
                    TextBox txtIdate = ((TextBox)e.Item.FindControl("txtdateabc"));
                    string  date;
                    if (txtIdate.Text == "")
                    {
                        date = "1/1/2001";
                    }
                    else
                    {
                        date = txtIdate.Text.Split('/')[1] + "/" + txtIdate.Text.Split('/')[0] + "/" + txtIdate.Text.Split('/')[2];
                    }
                    _objDCFT.InvoiceDate  = Convert.ToDateTime(date);
                    _objDCFT.AvailableQty = Convert.ToInt32(strFY);
                    _objDCFT.Save_FrightTax_Details(1);


                    //  _objDCConfirmQtyDetails.SaveConfirmDetails();

                    stDS            = new DataSet();
                    docno.InnerHtml = txtDocno.Text.Trim();
                    // stDS = DCDetails.Get_SubDocId_And_ItsRecords_By_DocNo(Convert.ToInt32(txtDocno.Text), "confirmed",Convert.ToInt32(strFY));



                    //  RepDetailsConfirm.DataSource = stDS.Tables[0];
                    //   RepDetailsConfirm.DataBind();
                    #endregion
                    MessageBox("Invoice Updated successfully " + subconfirmdoc);

                    lblmessage.InnerHtml = "Last updated Invoice no. : " + subconfirmdoc;


                    stDS            = new DataSet();
                    docno.InnerHtml = txtDocno.Text.Trim();
                    stDS            = DCDetails.Get_SubDocId_And_ItsRecords_By_DocNo(Convert.ToInt32(txtDocno.Text), "Edit", Convert.ToInt32(strFY));
                    RepDetailsConfirm.DataSource = stDS.Tables[0];
                    RepDetailsConfirm.DataBind();
                }
                catch (Exception ex)
                {
                    MessageBox(ex.Message.ToString());
                }
            }
        }
    }
コード例 #2
0
    protected void RepDetailsConfirm_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (Session["saved"] == null)
            {
                Session["saved"] = "s";
            }

            if (Session["saved"].ToString() != e.CommandArgument.ToString().Trim())
            {
                //if (e.CommandName == "AddToCart")
                {
                    bool Auth = DCMaster.Get_DocumentNum_Authentication(Convert.ToInt32(txtDocno.Text), Convert.ToInt32(strFY));
                    if (Auth)
                    {
                        MessageBox("Document no is not available");
                        txtDocno.Focus();
                    }
                    else
                    {
                        DCConfirmQtyDetails _objDCConfirmQtyDetails = new DCConfirmQtyDetails();
                        DCMaster            _objDCMaster            = new DCMaster();
                        DCConfirmQtyDetails _objDCFT = new DCConfirmQtyDetails();
                        //ActualInvoiceDetails _objactualinvoice = new ActualInvoiceDetails();
                        Other_Z.ActualInvoice_Details.ActualInvoice_DetailsProp _objactualinvoice = new Other_Z.ActualInvoice_Details.ActualInvoice_DetailsProp();
                        Other_Z.ActualInvoice_Details ObjBal = new Other_Z.ActualInvoice_Details();

                        try
                        {
                            #region ActulInvoice
                            Repeater objrep  = (Repeater)this.FindControl("RepDetailsConfirm");
                            GridView objgrid = (GridView)objrep.Items[e.Item.ItemIndex].FindControl("grdapproval");

                            Other_Z.ActualInvoice_Details.ActualInvoice_DetailsProp NewObj = new Other_Z.ActualInvoice_Details.ActualInvoice_DetailsProp();
                            decimal TotalNetAmount = 0;
                            foreach (GridViewRow row in objgrid.Rows)
                            {
                                NewObj.Amount   = Convert.ToInt32(((Label)row.FindControl("lblAqty")).Text) * (Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) - (Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) * Convert.ToDecimal(((TextBox)row.FindControl("txtdiscount")).Text) / 100));
                                NewObj.GSTPer   = Convert.ToDecimal(((Label)row.FindControl("lblGstPer")).Text);
                                TotalNetAmount += Convert.ToDecimal(NewObj.Amount * NewObj.GSTPer / 100);
                            }

                            foreach (GridViewRow row in objgrid.Rows)
                            {
                                _objactualinvoice.DocumentNo  = Convert.ToInt32(txtDocno.Text);
                                _objactualinvoice.SubDocId    = Convert.ToDecimal(e.CommandArgument.ToString().Trim());
                                _objactualinvoice.BookCode    = ((Label)row.FindControl("lblbookC")).Text;
                                _objactualinvoice.BookName    = ((Label)row.FindControl("lblbookN")).Text;
                                _objactualinvoice.Standard    = ((Label)row.FindControl("lblStandard")).Text;
                                _objactualinvoice.Medium      = ((Label)row.FindControl("lblMedium")).Text;
                                _objactualinvoice.Rate        = Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text);
                                _objactualinvoice.Quantity    = Convert.ToInt32(((Label)row.FindControl("lblAqty")).Text);
                                _objactualinvoice.Discount    = Convert.ToDecimal(((TextBox)row.FindControl("txtdiscount")).Text);
                                _objactualinvoice.Amount      = Convert.ToInt32(((Label)row.FindControl("lblAqty")).Text) * (Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) - (Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) * Convert.ToDecimal(((TextBox)row.FindControl("txtdiscount")).Text) / 100));
                                _objactualinvoice.Freight     = Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text);
                                _objactualinvoice.Tax         = Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                                _objactualinvoice.Transporter = (((TextBox)e.Item.FindControl("lbltransporter")).Text);
                                _objactualinvoice.LRNo        = (((TextBox)e.Item.FindControl("txtlrno")).Text);

                                _objactualinvoice.Bundles           = (((TextBox)e.Item.FindControl("txtbundles")).Text);
                                _objactualinvoice.CreatedBy         = Convert.ToString(Session["UserName"]);
                                _objactualinvoice.FinancialYearFrom = strFY;

                                _objactualinvoice.HSNCode     = ((Label)row.FindControl("lblHsnCode")).Text;
                                _objactualinvoice.GSTPer      = Convert.ToDecimal(((Label)row.FindControl("lblGstPer")).Text);
                                _objactualinvoice.Typ         = e.CommandName == "GSTInvoice" ? "G" : "N";
                                _objactualinvoice.GSTAmt      = Convert.ToDecimal(_objactualinvoice.Amount * _objactualinvoice.GSTPer / 100);
                                _objactualinvoice.TotalAmount = Convert.ToDecimal(getTotalValues(objgrid).ToString()) + TotalNetAmount + Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text); //+ Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                                //_objactualinvoice.GSTPer=

                                TextBox txtIdate1  = ((TextBox)e.Item.FindControl("txtdateabc"));
                                TextBox txtLrdate1 = ((TextBox)e.Item.FindControl("txtlrdate"));
                                _objactualinvoice.IsActive  = true;
                                _objactualinvoice.IsDeleted = false;
                                string date1;
                                string lrdate;
                                if (txtIdate1.Text == "")
                                {
                                    date1 = "1/1/2001";
                                }
                                else
                                {
                                    date1 = txtIdate1.Text.Split('/')[2] + "/" + txtIdate1.Text.Split('/')[1] + "/" + txtIdate1.Text.Split('/')[0];
                                }
                                if (txtLrdate1.Text == "")
                                {
                                    lrdate = "1/1/2001";
                                }
                                else
                                {
                                    lrdate = txtLrdate1.Text.Split('/')[2] + "/" + txtLrdate1.Text.Split('/')[1] + "/" + txtLrdate1.Text.Split('/')[0];
                                }
                                _objactualinvoice.InvoiceDate = Convert.ToDateTime(date1);

                                _objactualinvoice.LRDate  = Convert.ToDateTime(lrdate);
                                _objactualinvoice.Remark1 = "";
                                _objactualinvoice.Remark2 = "";
                                _objactualinvoice.Remark3 = "";
                                ObjBal.SaveActualInvoiceDetails(_objactualinvoice);
                                // (TextBox)e.Item.FindControl("txtfrieght");
                            }

                            #endregion

                            #region InvoiceCreate
                            decimal subconfirmdoc = Convert.ToDecimal(e.CommandArgument.ToString().Trim());
                            _objDCConfirmQtyDetails.IsCreateInvoice  = true;
                            _objDCConfirmQtyDetails.CreatedInvoiceBy = Convert.ToString(Session["UserName"]);
                            _objDCConfirmQtyDetails.SubDocNo         = subconfirmdoc;
                            // For financial year
                            _objDCConfirmQtyDetails.AvailableQty = Convert.ToInt32(strFY);
                            _objDCMaster.DocNo = Convert.ToInt32(txtDocno.Text);

                            // Save Freight and tax Details
                            frieght     = Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text);
                            tax         = Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                            temp        = Convert.ToDecimal(tamount.Text) + frieght + tax;
                            totalamount = Convert.ToDecimal(tamount.Text);

                            _objDCFT.DocumentNo = Convert.ToInt32(txtDocno.Text);
                            _objDCFT.SubDocNo   = subconfirmdoc;
                            _objDCFT.Freight    = Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text);
                            _objDCFT.Tax        = Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                            decimal TotalAmt = Convert.ToDecimal(getTotalValues(objgrid).ToString()) + Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text) + Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                            _objDCFT.TotalAmount = Convert.ToDecimal(getTotalValues(objgrid).ToString()) + Convert.ToDecimal(((TextBox)e.Item.FindControl("txtfrieght")).Text) + Convert.ToDecimal(((TextBox)e.Item.FindControl("txttax")).Text);
                            _objDCFT.LRNo        = (((TextBox)e.Item.FindControl("txtlrno")).Text);
                            TextBox txtIdate = ((TextBox)e.Item.FindControl("txtdateabc"));
                            string  date;
                            if (txtIdate.Text == "")
                            {
                                date = "1/1/2001";
                            }
                            else
                            {
                                date = txtIdate.Text.Split('/')[2] + "/" + txtIdate.Text.Split('/')[1] + "/" + txtIdate.Text.Split('/')[0];
                            }
                            _objDCFT.InvoiceDate  = Convert.ToDateTime(date);
                            _objDCFT.AvailableQty = Convert.ToInt32(strFY);
                            _objDCFT.Save_FrightTax_Details(1);


                            _objDCConfirmQtyDetails.SaveConfirmDetails(1);

                            stDS            = new DataSet();
                            docno.InnerHtml = txtDocno.Text.Trim();
                            // stDS = DCDetails.Get_SubDocId_And_ItsRecords_By_DocNo(Convert.ToInt32(txtDocno.Text), "confirmed", Convert.ToInt32(strFY));

                            //if (ViewState["staticDS"] != null)
                            //{
                            //    stDS = (DataSet)ViewState["staticDS"];
                            //}
                            //else
                            //{
                            stDS = DCDetails.Get_SubDocId_And_ItsRecords_By_DocNo(Convert.ToInt32(txtDocno.Text), "confirmed", Convert.ToInt32(strFY));

                            //}


                            RepDetailsConfirm.DataSource = stDS.Tables[0];
                            RepDetailsConfirm.DataBind();
                            #endregion

                            MessageBox("Invoice created successfully " + subconfirmdoc);

                            lblmessage.InnerHtml = "Last confirm doc no. : " + subconfirmdoc;

                            if (e.CommandName == "PrintInvoice")
                            {
                                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "window", "f_open_window_max('print/ReportInvoicePrint.aspx?d=" + txtOrgDocNo.Text + "&sd=" + subconfirmdoc + "&type=with" + "')", true);
                            }


                            if (Rptrpending.Items.Count == 1)
                            {
                                Rptrpending.DataSource = DCMaster.Get_ApprovedDocNo(Convert.ToInt32(strFY));
                                Rptrpending.DataBind();
                                //updateapprove.Update();
                            }
                            if (RepDetailsConfirm.Items.Count == 0)
                            {
                                Rptrpending.DataSource = DCMaster.Get_ApprovedDocNo(Convert.ToInt32(strFY));
                                Rptrpending.DataBind();
                                upDocNo.Update();
                                docno.InnerHtml       = "";
                                lblcustname.InnerHtml = "";
                                lblempname1.InnerHtml = "";
                                //updateapprove.Update();
                            }
                            if (SMSSend.Text.ToUpper() == "YES")
                            {
                                sendMsg(lblMobNo.Text.Trim(), subconfirmdoc.ToString(), string.Format("{0:0.00}", TotalAmt).ToString(),
                                        (((TextBox)e.Item.FindControl("lbltransporter")).Text),
                                        (((TextBox)e.Item.FindControl("txtlrno")).Text),
                                        (((TextBox)e.Item.FindControl("txtbundles")).Text),
                                        txtIdate.Text.Trim());


                                //sendZoalMsg(((Label)e.Item.FindControl("lblCustId1")).Text, lblcustname.InnerHtml.Trim(), lblMobNo.Text.Trim(), subconfirmdoc.ToString(), string.Format("{0:0.00}", TotalAmt).ToString(),
                                //    (((TextBox)e.Item.FindControl("lbltransporter")).Text),
                                //    (((TextBox)e.Item.FindControl("txtlrno")).Text),
                                //    (((TextBox)e.Item.FindControl("txtbundles")).Text),
                                //    txtIdate.Text.Trim());
                            }
                            //lblempname1.InnerHtml = "";
                            //lblcustname.InnerHtml = "";
                            // docno.InnerHtml = "" ;
                        }
                        catch (SqlException ex)
                        {
                            Response.Write(ex.Message.ToString());
                        }
                        catch (Exception ex1)
                        {
                            Response.Write(ex1.Message.ToString());
                        }
                    }
                }
            }

            ViewState["staticDS"] = null;
            Session["saved"]      = e.CommandArgument.ToString().Trim();
            updategenerate.Update();
        }
        catch (Exception ex)
        {
            throw;
        }
    }