protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            int invId = SafeValue.SafeInt(Request.QueryString["id"], 0);
            int index = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(string.Format("Select max(QuoteLineNo) FROM AirQuoteDet1 where QuoteId='{0}'", invId)), 1);
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    index++;
                    int sequenceId = list[i].docId;

                    string    sql = string.Format(@"SELECT ChgCode, Currency,ExRate, Price, Unit, MinAmt, Rmk, Qty, Amt, GstType, Gst, GroupTitle, 
                      ChgDes FROM AirQuoteDet1 where SequenceId='{0}' order by QuoteLineNo", sequenceId);
                    DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                    if (tab.Rows.Count == 1)
                    {
                        string  chgCode     = tab.Rows[0]["ChgCode"].ToString();
                        string  chgDes      = tab.Rows[0]["ChgDes"].ToString();
                        string  currencyDes = tab.Rows[0]["Currency"].ToString();
                        decimal exRate      = SafeValue.SafeDecimal(tab.Rows[0]["ExRate"], 1);
                        decimal price       = SafeValue.SafeDecimal(tab.Rows[0]["Price"], 0);
                        string  unit        = tab.Rows[0]["Unit"].ToString();
                        decimal minAmt      = SafeValue.SafeDecimal(tab.Rows[0]["MinAmt"], 0);
                        decimal amt         = SafeValue.SafeDecimal(tab.Rows[0]["Amt"], 0);
                        string  rmk         = tab.Rows[0]["Rmk"].ToString();
                        decimal qty         = SafeValue.SafeDecimal(tab.Rows[0]["Qty"], 1);
                        decimal gst         = SafeValue.SafeDecimal(tab.Rows[0]["Gst"], 0);
                        string  gstType     = tab.Rows[0]["GstType"].ToString();
                        string  groupTitle  = SafeValue.SafeString(tab.Rows[0]["GroupTitle"], "");

                        AirQuoteDet1 det = new AirQuoteDet1();
                        det.Amt         = amt;
                        det.ChgCode     = chgCode;
                        det.ChgDes      = chgDes;
                        det.Currency    = currencyDes;
                        det.ExRate      = exRate;
                        det.GroupTitle  = groupTitle;
                        det.Gst         = gst;
                        det.GstType     = gstType;
                        det.MinAmt      = minAmt;
                        det.Price       = price;
                        det.Qty         = qty;
                        det.QuoteId     = invId.ToString();
                        det.QuoteLineNo = index;
                        det.Rmk         = rmk;
                        det.Unit        = unit;
                        C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                        C2.Manager.ORManager.PersistChanges(det);
                    }
                }
                catch { }
            }
        }
        else
        {
            e.Result = "Error, Pls refresh your invoice";
        }
    }
Esempio n. 2
0
    protected void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["no"] != null)
        {
            string repId = Request.QueryString["no"].ToString();
            try
            {
                for (int i = 0; i < list.Count; i++)
                {
                    string docId = list[i].docId;

                    string    sql = string.Format("SELECT ChgCode,ChgDes,ExRate, Currency,Qty, Price, Unit, MinAmt, Rmk,GstType,Gst,Amt FROM AirQuoteDet1 where SequenceId='{0}'", docId);
                    DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                    if (tab.Rows.Count == 1)
                    {
                        string  chgCode  = tab.Rows[0]["ChgCode"].ToString();
                        string  chgDes   = tab.Rows[0]["ChgDes"].ToString();
                        decimal qty      = SafeValue.SafeDecimal(tab.Rows[0]["Qty"], 1);
                        decimal price    = SafeValue.SafeDecimal(tab.Rows[0]["Price"], 0);
                        decimal minAmt   = SafeValue.SafeDecimal(tab.Rows[0]["MinAmt"], 0);
                        string  currency = tab.Rows[0]["Currency"].ToString();
                        decimal exRate   = SafeValue.SafeDecimal(tab.Rows[0]["ExRate"], 1);
                        string  unit     = tab.Rows[0]["Unit"].ToString();
                        string  rmk      = tab.Rows[0]["Rmk"].ToString();
                        decimal amt      = SafeValue.SafeDecimal(tab.Rows[0]["Amt"], 0);
                        decimal gst      = SafeValue.SafeDecimal(tab.Rows[0]["Gst"], 0);
                        string  gstType  = tab.Rows[0]["GstType"].ToString();

                        C2.AirQuoteDet1 repDet = new AirQuoteDet1();
                        repDet.ChgCode   = chgCode;
                        repDet.ChgDes    = chgDes;
                        repDet.Currency  = currency;
                        repDet.ExRate    = exRate;
                        repDet.FclLclInd = "Lcl";
                        repDet.MinAmt    = minAmt;
                        repDet.Price     = price;
                        repDet.QuoteId   = repId;
                        repDet.Qty       = qty;
                        repDet.GstType   = gstType;
                        repDet.Gst       = gst;
                        repDet.Amt       = amt;
                        string sql_detCnt = "select max(QuoteLineNo) from AirQuoteDet1 where QuoteId='" + repId + "'";
                        int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                        repDet.QuoteLineNo = lineNo;
                        repDet.Rmk         = rmk;
                        repDet.Unit        = unit;
                        repDet.GroupTitle  = "";
                        C2.Manager.ORManager.StartTracking(repDet, Wilson.ORMapper.InitialState.Inserted);
                        C2.Manager.ORManager.PersistChanges(repDet);
                    }
                }
                e.Result = "";
            }
            catch { }
        }
        else
        {
            e.Result = "Please keyin select party ";
        }
    }