コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String strConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            creditDAL = new CreditNotesDAL(strConnectionString);
            String[] arrCreditNote;

            if (!String.IsNullOrEmpty(Request.QueryString["CreditNoteID"]))
            {
                CREDITNOTEID                 = Request.QueryString["CreditNoteID"].ToString();
                hdnCreditNoteID.Value        = CREDITNOTEID.ToString();
                hdnEditCreditNote.Value      = creditDAL.getSavedCreditNote(Int32.Parse(CREDITNOTEID));
                hdnEditCreditNoteItems.Value = creditDAL.getSavedCreditNoteItems(Int32.Parse(CREDITNOTEID));
                arrCreditNote                = creditDAL.getSavedCreditNote(Int32.Parse(CREDITNOTEID)).ToString().Split(':');
                STATUS = arrCreditNote[8].ToString();
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CompanyID"]))
            {
                COMPANYID = Request.QueryString["CompanyID"].ToString();
            }

            if (!String.IsNullOrEmpty(STATUS) && STATUS.Equals("PENDING"))
            {
                btnPublish.Visible = true;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String strConnString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            notesDAL = new CreditNotesDAL(strConnString);
            String strCompanyID = Request.QueryString["companyid"].ToString();

            Response.Write(notesDAL.getCreditNotes(Int32.Parse(strCompanyID)));
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.Form["creditnoteid"]))
            {
                int            OrderID       = Int32.Parse(Request.Form["creditnoteid"].ToString());
                CreditNotesDAL creditdal     = new CreditNotesDAL(strConnSitring);
                CommissionDAL  dal_Commision = new DeltoneCRM_DAL.CommissionDAL(strConnSitring);

                String pre_status        = creditdal.getCurrentCreditNoteStatus(OrderID); //Fetch the PRevious Status
                String strCreditNoteGuid = creditdal.getCreditNote_XeroGuid(OrderID);     //Fetch the credit note Xero Guid

                String Result = String.Empty;

                if (!String.IsNullOrEmpty(strCreditNoteGuid))
                {
                    xero = new XeroIntergration();
                    Repository repos = xero.CreateRepository();
                    XeroApi.Model.CreditNote cancelCreditNote = xero.CancelCreditNote(OrderID, repos, pre_status, strCreditNoteGuid);
                    String connectionstring = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
                    //CANCEL THE CREDIT NOTE IN DELTONE SYSTEM
                    Result = (cancelCreditNote != null) ? "SUCCESS" : "ERROR";
                    var previousValues = pre_status;
                    if (Result.Equals("SUCCESS"))
                    {
                        var columnName = "Status";
                        var talbeName  = "CreditNote";
                        var ActionType = "CANCELLED";
                        int primaryKey = OrderID;

                        var orderIdForCreditNote = new CreditNotesDAL(connectionstring).getOrderIDFromCreditID(OrderID);

                        var newvalues = " CreditNote Id " + OrderID + " :Credit Ortder Status changed from " + previousValues + " to CANCELLED";



                        var           loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString());
                        SqlConnection conn           = new SqlConnection();
                        conn.ConnectionString = connectionstring;
                        var strCompanyID = new CreditNotesDAL(connectionstring).getCompanyIDFromCreditID(OrderID);

                        new DeltoneCRM_DAL.CompanyDAL(connectionstring).CreateActionONAuditLog(previousValues, newvalues, loggedInUserId, conn, 0,
                                                                                               columnName, talbeName, ActionType, primaryKey, Convert.ToInt32(strCompanyID));

                        creditdal.CancelCreditNote(OrderID);


                        dal_Commision.RemoveCommissionEntry(OrderID, "CREDITNOTE");
                    }
                }
                else
                {
                    Result = "ERROR";
                }
                Response.Write(Result);
            }
        }
コード例 #4
0
        private string GetAllSuppNames(string str_ORDERID)
        {
            var connString    = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var creditnotedal = new CreditNotesDAL(connString);

            var allSupp = creditnotedal.GetSuppliersForCreditNoteById(str_ORDERID);

            string joined = string.Join(",", allSupp);

            return(joined);
        }
        public OrderAndCompanyContact GetCompanyContact(string orderId)
        {
            var obj        = new OrderAndCompanyContact();
            var connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var orderdal   = new CreditNotesDAL(connString);
            var creditObj  = orderdal.getCreditNoteObj(Convert.ToInt32(orderId));

            obj.ContactId = creditObj.ContactId;
            obj.CompanyId = creditObj.CompID;

            return(obj);
        }
コード例 #6
0
        private void sentRMATOCustomer(string RmaId)
        {
            var ramIdC   = Convert.ToInt32(RmaId);
            var rmaTrack = GetCreditNoteIdFromRAMTracking(ramIdC);


            String     strConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            ContactDAL cdal               = new ContactDAL(strConnectionString);
            var        orderDal           = new OrderDAL(strConnectionString);
            var        creditNoteDal      = new CreditNotesDAL(strConnectionString);
            var        ordersendEmail     = new OrderSendEmailDAL(strConnectionString);
            var        creditNoteObj      = creditNoteDal.getCreditNoteObj(rmaTrack.CreditNoteID);
            var        creditEmailHandler = new CreditNoteRMAHandler(strConnectionString);

            if (creditNoteObj.IsAvail)
            {
                if (creditNoteObj.Reason == "CHANGED PRINTER")
                {
                    var contactId = Convert.ToInt32(creditNoteObj.ContactId);
                    var contact   = cdal.GetContactByContactId(contactId);
                    if (!string.IsNullOrEmpty(creditNoteObj.Reason))
                    {
                        var orderID            = Convert.ToInt32(creditNoteObj.OrderId);
                        var xeroOrderDTSnumber = orderDal.getXeroDTSID(orderID);
                        var subject            = "RMA Request for " + creditNoteObj.Reason;

                        var body = "Hi , <br/>  RMA Request  for this order number :"
                                   + xeroOrderDTSnumber;
                        if (!string.IsNullOrEmpty(rmaTrack.SupplierRMANumber))
                        {
                            body = body + "<br/> Supplier RMA number " + rmaTrack.SupplierRMANumber;
                        }
                        if (!string.IsNullOrEmpty(rmaTrack.TrackingNumber))
                        {
                            body = body + " <br/> TrackingNumber  " + rmaTrack.TrackingNumber;
                        }

                        var toEmail = contact.Email;

                        var from     = "*****@*****.**";
                        var fromName = "Deltonesolutions";

                        var res = creditEmailHandler.SendCreditNoteEmail(rmaTrack.CreditNoteID, "", "", from, fromName, toEmail,
                                                                         "", "", subject, body, true, null);

                        if (res)
                        {
                            creditEmailHandler.UpdateRMISentToCustomer(rmaTrack.CreditNoteID);
                        }
                    }
                }
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String strConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            CONNSTRING    = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            creditNoteDAL = new CreditNotesDAL(strConnectionString);
            prodal        = new ProItemDAL(strConnectionString);

            if (!String.IsNullOrEmpty(Request.QueryString["ContactID"]))
            {
                CONTACTID = Request.QueryString["ContactID"].ToString();
                String   strCreditNoteContact = creditNoteDAL.FetchContactDetails(Int32.Parse(CONTACTID));
                String[] arrContact           = strCreditNoteContact.Split(':');
                ContactInfo.InnerHtml             = arrContact[0].ToString();
                CompanyInfo.InnerHtml             = arrContact[3].ToString();
                BillingAddress.InnerHtml          = arrContact[1].ToString();
                hdnCreditNoteContactDetails.Value = strCreditNoteContact;
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CompanyID"]))
            {
                COMPNAYID = Request.QueryString["CompanyID"].ToString();
                //Create the Session for the CompanyID
                Session["OpenedCompanyID"] = COMPNAYID;
                ACCOUNT_OWNER_ID.Value     = companydal.getCompanyOwnershipAdminID(COMPNAYID);
                ACCOUNT_OWNER_TXT.Value    = companydal.getCompanyAccountOwner(Int32.Parse(COMPNAYID));
            }

            if (!String.IsNullOrEmpty(Request.QueryString["OrderID"]))
            {
                ORDERID             = Request.QueryString["OrderID"].ToString();
                dtsnumber.InnerText = creditNoteDAL.getXeroOrderNumber(ORDERID);
                hdnEditOrder.Value  = creditNoteDAL.getOrderDetails(ORDERID.ToString());
                String[] arr_Order = creditNoteDAL.getOrderDetails(ORDERID.ToString()).Split(':');
                OrderNumber.InnerHtml   = "Order:" + arr_Order[3].ToString();
                hdnEditOrderItems.Value = creditNoteDAL.getOrderItemsbyOrderId(ORDERID.ToString(), strConnectionString);
                PROCOST.Value           = prodal.getPromotionlCost(Int32.Parse(ORDERID));
                PopulateDropDownList(Int32.Parse(COMPNAYID), Int32.Parse(ORDERID));
                hdnORDERID.Value    = Request.QueryString["OrderID"].ToString();
                COMMISH_SPLIT.Value = orddal.getCommishSplitBoolean(Int32.Parse(Request.QueryString["OrderID"].ToString()));

                SALESPERON_ID.Value = orddal.getSalespersonByID(Int32.Parse(Request.QueryString["OrderID"].ToString()));

                SALESPERSON_TXT.Value = orddal.getSalespersonName(Int32.Parse(Request.QueryString["OrderID"].ToString()));
            }
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            if (Session["LoggedUserID"] == null)
            {
                return;
            }
            creditnotedal = new CreditNotesDAL(connString);
            if (Request["ordID"] != null)
            {
                str_AccountID = Request["ordID"].ToString();
            }
            if (Request["crID"] != null)
            {
                str_CreditId = Request["crID"].ToString();
            }

            if (Request["suNa"] != null)
            {
                str_SuppName = Request["suNa"].ToString();
            }

            if (IsPostBack)
            {
                UploadFile(sender, e);
            }
            if (!IsPostBack)
            {
                var allSupp = creditnotedal.GetSuppliersForCreditNoteById(str_CreditId);
                if (!IsPostBack)
                {
                    foreach (var item in allSupp)
                    {
                        suppliernameDrop.Items.Add(new System.Web.UI.WebControls.ListItem(item, item));
                    }
                }
            }

            LoadUploadedFiles();



            // var ttt= string.Format("openTab({0});", "test");
        }
コード例 #9
0
        protected void btnOrderSubmit_Click(object sender, EventArgs e)
        {
            String strDelCost     = String.Empty;
            float  Total          = 0;;
            float  SubTotal       = 0;
            float  SplitVolume    = 0;
            String strCreditItems = String.Empty;
            String strCreatedBy   = String.Empty;

            String ACCOUNT_OWNER_ID_VALUE  = ACCOUNT_OWNER_ID.Value;;
            String ACCOUNT_OWNER_TXT_VALUE = ACCOUNT_OWNER_TXT.Value;

            String SALESPERSON_ID_VALUE  = SALESPERON_ID.Value;
            String SALESPERSON_TXT_VALUE = SALESPERSON_TXT.Value;

            String CommishSplit = COMMISH_SPLIT.Value;

            if (CommishSplit == "1")
            {
                SplitVolume = float.Parse(VOLUME_SPLIT_AMOUNT.Value);
            }
            else
            {
                SplitVolume = 0;
            }


            if (!String.IsNullOrEmpty(Session["LoggedUser"] as String))
            {
                strCreatedBy = Session["LoggedUser"].ToString();
            }

            if (!String.IsNullOrEmpty(CusDelCostItems.Value))
            {
                strDelCost = CusDelCostItems.Value.ToString();
            }

            if (!String.IsNullOrEmpty(hdnTotal.Value))
            {
                Total = float.Parse(hdnTotal.Value);
            }

            if (!String.IsNullOrEmpty(hdnSubTotal.Value))
            {
                SubTotal = float.Parse(hdnSubTotal.Value);
            }

            if (!String.IsNullOrEmpty(OrderItems.Value))
            {
                strCreditItems = OrderItems.Value.ToString();
            }

            if (COMMISH_SPLIT.Value == "1")
            {
                SplitVolume = float.Parse(VOLUME_SPLIT_AMOUNT.Value);
            }
            else
            {
                SplitVolume = 0;
            }

            String CreditNoteReason    = txtCreditReason.Text;
            String Notes               = OrderNotes.Text;
            String strConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            creditNoteDAL = new CreditNotesDAL(strConnectionString);
            ContactDAL cdal = new ContactDAL(strConnectionString);

            String strGuid = cdal.getXeroGuid_ForContact(Int32.Parse(CONTACTID));

            ///Create the  XERO Entry  first
            XeroIntergration xero = new XeroIntergration();
            Repository       res  = xero.CreateRepository();

            List <DeltoneItem> cr_items = CreateCreaitItems(strCreditItems);

            XeroApi.Model.CreditNote deltone_CreditNote = xero.CreateCreditNote(res, strGuid, String.Empty, String.Empty, cr_items);

            //CreditNoteReason= txtCreditReason.Text;
            CreditNoteReason = TYPEOFCREDIT.Value;

            //Get Customer delcost items and suppleir delcost items given by OrderID
            OrderDAL ordal                = new OrderDAL(CONNSTRING);
            String   CustomerDelItems     = ordal.getCustomerDelItems(Int32.Parse(ORDERID));
            String   SuppDelItems         = ordal.getSupplierDelItems(Int32.Parse(ORDERID));
            var      creditNoteMainString = "";

            if (deltone_CreditNote != null)
            {
                //Write  to Deltone DB  Modified here
                if (creditNoteDAL.CreateCreditNote(Int32.Parse(COMPNAYID), Int32.Parse(CONTACTID), Total,
                                                   strDelCost, strCreatedBy, Int32.Parse(ORDERID), "PENDING", CreditNoteReason, Notes,
                                                   SuppDelItems, CustomerDelItems, SubTotal, SplitVolume, ACCOUNT_OWNER_ID_VALUE,
                                                   ACCOUNT_OWNER_TXT_VALUE, SALESPERSON_ID_VALUE, SALESPERSON_TXT_VALUE, CommishSplit) > 0)
                {
                    var connectionstring = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
                    var companyName      = new CompanyDAL(connectionstring).getCompanyNameByID(COMPNAYID);

                    int CreatedCreditNoteID = creditNoteDAL.FetchLastCreatedCreaditNoteID(strCreatedBy);
                    creditNoteMainString = " CreditNote  Id : " + CreatedCreditNoteID
                                           + " Created By :" + strCreatedBy + " Notes :" + Notes + " Credit Reason " + CreditNoteReason + " Status: PENDING ";
                    if (!String.IsNullOrEmpty(strCreditItems))
                    {
                        CreateCreditNoteItems(strCreditItems, CreatedCreditNoteID, creditNoteDAL, strCreatedBy, Convert.ToInt32(COMPNAYID), creditNoteMainString);
                    }

                    // Create entries for the RMAs
                    creditNoteDAL.BuildRMAList(ORDERID, CreatedCreditNoteID.ToString());

                    //Update  the Deltone Table With the Xero Entry
                    creditNoteDAL.UpdateWithXeroEntry(CreatedCreditNoteID, deltone_CreditNote.CreditNoteID.ToString(), deltone_CreditNote.CreditNoteNumber.ToString());

                    //Add ORder Supplier Notes as Type 'Credit'
                    Dictionary <String, String> di_notes = ordal.getOrderSupplierNotes(Int32.Parse(ORDERID));

                    //ordal.CreateSupplerNotes(Int32.Parse(ORDERID), deltone_CreditNote.CreditNoteNumber.ToString(), di_notes);
                    creditNoteDAL.CreateSupplerNotes(CreatedCreditNoteID, deltone_CreditNote.CreditNoteNumber.ToString(), di_notes);

                    #region Commission_Calculation

                    CreditNotesDAL cnDal = new CreditNotesDAL(CONNSTRING);
                    float          AccountOwnerCommission = 0;
                    float          SalespersonCommission  = 0;

                    AccountOwnerCommission = float.Parse(ACCOUNT_OWNER_COMMISH.Value);
                    AccountOwnerCommission = -AccountOwnerCommission;

                    if (SALESPERSON_COMMISH.Value != "")
                    {
                        SalespersonCommission = float.Parse(SALESPERSON_COMMISH.Value);
                        SalespersonCommission = -SalespersonCommission;
                    }



                    if (COMMISH_SPLIT.Value == "0")
                    {
                        cnDal.SplitCommission(CreatedCreditNoteID, Int32.Parse(COMPNAYID), Int32.Parse(ACCOUNT_OWNER_ID.Value), AccountOwnerCommission, "PENDING");
                    }
                    else
                    {
                        cnDal.SplitCommission(CreatedCreditNoteID, Int32.Parse(COMPNAYID), Int32.Parse(ACCOUNT_OWNER_ID.Value), AccountOwnerCommission, "PENDING");
                        cnDal.SplitCommission(CreatedCreditNoteID, Int32.Parse(COMPNAYID), Int32.Parse(SALESPERON_ID.Value), SalespersonCommission, "PENDING");
                    }

                    /*
                     * commission = float.Parse(hdnCommision.Value.ToString());
                     * commission = -commission;
                     *
                     *
                     *
                     *
                     * if (Session["LoggedUserID"] != null)
                     * {
                     *
                     *
                     *  cnDal.SplitCommission(CreatedCreditNoteID, Int32.Parse(COMPNAYID), Int32.Parse(Session["LoggedUserID"].ToString()), commission, "PENDING");
                     * }*/

                    #endregion  Commission_Calculation

                    ///Dialog  BOX  Stating Success Message and Redirection

                    String Message     = "<h2>CREDIT NOTE: " + deltone_CreditNote.CreditNoteNumber + " HAS BEEN CREATED</h2>";
                    String NavigateUrl = "CreditNotes/AllCreditNotes.aspx";
                    String PrintURl    = String.Empty;
                    string strScript   = "<script language='javascript'>$(document).ready(function (){SubmitDialog('" + Message + "','" + NavigateUrl + "','" + PrintURl + "'); });</script>";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "PopupCP", strScript, false);
                    //Response.Redirect("CreditNotes/AllCreditNotes.aspx");
                }
            }
            else
            {
                //Couldnt  Write in to Xero Message with  Dialog BOX
                String Message     = "<h2>ERROR OCCURED CREATING CREDIT NOTE</h2>";
                String NavigateUrl = "CreditNotes/AllCreditNotes.aspx";
                String PrintURl    = String.Empty;
                string strScript   = "<script language='javascript'>$(document).ready(function (){SubmitDialog('" + Message + "','" + NavigateUrl + "','" + PrintURl + "'); });</script>";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "PopupCP", strScript, false);
            }
        }
コード例 #10
0
        /// <summary>
        /// This method creates Credit Note Items
        /// </summary>
        /// <param name="strCreditItems"></param>
        /// <param name="CreditNoteID"></param>
        /// <param name="crDAL"></param>
        /// <param name="CreatedBy"></param>
        protected void CreateCreditNoteItems(String strCreditItems, int CreditNoteID,
                                             CreditNotesDAL crDAL, String CreatedBy, int companyId, string noteString = "")
        {
            String[] arrcreditItems = strCreditItems.Split('|');
            String[] line;
            string   noteItemsString = "";

            for (int i = 0; i < arrcreditItems.Length; i++)
            {
                if (!String.IsNullOrEmpty(arrcreditItems[i]))
                {
                    line = arrcreditItems[i].Split(',');
                    int RowsEffected = -1;

                    if (line[0].Contains("D/L Handling")) //If this is Delivery Handling Line
                    {
                        RowsEffected = crDAL.CreateCreditNoteItems(CreditNoteID, line[0].ToString(), 1,
                                                                   float.Parse(line[4].ToString()), 0, String.Empty, CreatedBy, "delivery");

                        noteItemsString = " Note Items : Description " + line[1].ToString() + ", Created By " + CreatedBy + " , SupplierName " + "delivery" + " ";
                    }

                    else
                    {
                        String description  = line[0].ToString();
                        String SupplierCode = line[1].ToString();
                        float  COGPrice     = float.Parse(line[2].ToString());
                        int    Qty          = Int32.Parse(line[3].ToString());
                        float  UnitPrice    = float.Parse(line[4].ToString());
                        //Modification done here
                        String SupplierName = line[5].ToString();

                        RowsEffected = crDAL.CreateCreditNoteItems(CreditNoteID, description, Qty, UnitPrice, COGPrice, SupplierCode, CreatedBy, SupplierName);
                        if (noteItemsString == "")
                        {
                            noteItemsString = " Note Items : Description " + line[1].ToString() + ", Created By " + CreatedBy + " , SupplierName " + SupplierName + " ";
                        }
                        else
                        {
                            noteItemsString = noteItemsString + " Description " + line[1].ToString() + ", Created By " + CreatedBy + " , SupplierName " + SupplierName + " ";
                        }
                    }
                }
            }

            var columnName = "CreditNote And CreditNote Items All columns";
            var talbeName  = "CreditNote And CreditNote Items";
            var ActionType = "Created";
            int primaryKey = CreditNoteID;

            var connectionstring = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            var newvalues = noteString + noteItemsString;

            var           loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString());
            SqlConnection conn           = new SqlConnection();

            conn.ConnectionString = connectionstring;

            new DeltoneCRM_DAL.CompanyDAL(connectionstring).CreateActionONAuditLog("", newvalues, loggedInUserId, conn, 0,
                                                                                   columnName, talbeName, ActionType, primaryKey, Convert.ToInt32(companyId));
        }
コード例 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection conn    = new SqlConnection();
            var           connStr = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            conn.ConnectionString = connStr;
            String     SqlStmt = @"UPDATE dbo.RMATracking SET SentToSupplier=@SentToSupplier, 
                      SentToSupplierDateTime=@SentToSupplierDateTime, ApprovedRMA=@ApprovedRMA, ApprovedRMADateTime=@ApprovedRMADateTime,
                      CreditInXero=@CreditInXero, CreditInXeroDateTime=@CreditInXeroDateTime, RMAToCustomer=@RMAToCustomer, 
                      RMAToCustomerDateTime=@RMAToCustomerDateTime, AdjustedNoteFromSupplier=@AdjustedNoteFromSupplier, 
                      AdjustedNoteFromSupplierDateTime=@AdjustedNoteFromSupplierDateTime, Status=@Status, SupplierRMANumber=@SupplierRMANumber, 
                TrackingNumber=@TrackingNumber , InHouse=@inHouse,Notes=@notes WHERE RMAID = " + Request.QueryString["QID"].ToString();
            SqlCommand cmd     = new SqlCommand(SqlStmt, conn);

            String RMAID = Request.QueryString["QID"].ToString();

            String STS      = Request.QueryString["STS"].ToString();
            String STSWrite = String.Empty;

            //DateTime STSDateTime = new DateTime();
            if (STS == "true")
            {
                STSWrite = "1";
            }
            else
            {
                STSWrite = "0";
            }

            String inHouse      = Request.QueryString["INHouse"].ToString();
            String inHouseWrite = String.Empty;
            String completed    = Request.QueryString["chk_Completed"].ToString();
            String notes        = Request.QueryString["Notes"].ToString();

            //DateTime STSDateTime = new DateTime();
            if (inHouse == "true")
            {
                inHouseWrite = "1";
            }
            else
            {
                inHouseWrite = "0";
            }

            cmd.Parameters.AddWithValue("@inHouse", inHouseWrite);

            String ARMA      = Request.QueryString["ARMA"].ToString();
            String ARMAWrite = String.Empty;

            if (ARMA == "true")
            {
                ARMAWrite = "1";
            }
            else
            {
                ARMAWrite = "0";
            }

            String CIX      = Request.QueryString["CIX"].ToString();
            String CIXWrite = String.Empty;

            if (CIX == "true")
            {
                CIXWrite = "1";
            }
            else
            {
                CIXWrite = "0";
            }

            String RTC      = Request.QueryString["RTC"].ToString();
            String RTCWrite = String.Empty;

            if (RTC == "true")
            {
                RTCWrite = "1";
            }
            else
            {
                RTCWrite = "0";
            }

            String ANFS      = Request.QueryString["ANFS"].ToString();
            String ANFSWrite = String.Empty;

            if (ANFS == "true")
            {
                ANFSWrite = "1";
            }
            else
            {
                ANFSWrite = "0";
            }

            String NewStatus = String.Empty;

            NewStatus = "IN PROGRESS";
            NewStatus = new CreditNotesDAL(connStr).RMAStatusByRMAID(RMAID);



            //if (inHouseWrite == "1")
            //{
            //    NewStatus = "COMPLETED";
            //}
            //else

            //    if (ANFSWrite == "1")
            //    {
            //        NewStatus = "COMPLETED";
            //    }
            //    else
            if (completed == "true")
            {
                NewStatus = "COMPLETED";
            }
            else
            {
                NewStatus = "IN PROGRESS";
            }

            //if (STS == "true" && ARMA == "true" && CIX == "true" && RTC == "true" && ANFS == "true")
            //{
            //    NewStatus = "COMPLETED";
            //}
            //else
            //{
            //    NewStatus = "IN PROGRESS";
            //}
            var notesValues = notes;

            var notesHistory = SetCreditNotesHistory(Convert.ToInt32(RMAID), notesValues);

            cmd.Parameters.AddWithValue("@notes", notesHistory);

            cmd.Parameters.AddWithValue("@SentToSupplier", STSWrite);
            if (STS == "true")
            {
                if (checkIfSTSHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@SentToSupplierDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@SentToSupplierDateTime", DateTime.Parse(checkIfSTSHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@SentToSupplierDateTime", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@ApprovedRMA", ARMAWrite);

            if (ARMA == "true")
            {
                if (checkIfARMAHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@ApprovedRMADateTime", DateTime.Today);
                    //  sentRMATOCustomer(RMAID);  // sent email to customer once RMA Approved
                }
                else
                {
                    cmd.Parameters.AddWithValue("@ApprovedRMADateTime", DateTime.Parse(checkIfARMAHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@ApprovedRMADateTime", DBNull.Value);
            }


            cmd.Parameters.AddWithValue("@CreditInXero", CIXWrite);

            if (CIX == "true")
            {
                if (checkIfCIXHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@CreditInXeroDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@CreditInXeroDateTime", DateTime.Parse(checkIfCIXHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreditInXeroDateTime", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@RMAToCustomer", RTCWrite);

            if (RTC == "true")
            {
                if (checkIfRTCHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@RMAToCustomerDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@RMAToCustomerDateTime", DateTime.Parse(checkIfRTCHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@RMAToCustomerDateTime", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplier", ANFSWrite);

            if (ANFS == "true")
            {
                if (checkIfANFSHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplierDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplierDateTime", DateTime.Parse(checkIfANFSHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplierDateTime", DBNull.Value);
            }
            cmd.Parameters.AddWithValue("@Status", NewStatus);
            cmd.Parameters.AddWithValue("@SupplierRMANumber", Request.QueryString["SRMAN"].ToString());
            cmd.Parameters.AddWithValue("@TrackingNumber", Request.QueryString["TN"].ToString());
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }
コード例 #12
0
        private static void UpdateRMANUmber(DeltoneCRM_DAL.CreditNoteRMAHandler.RMAUpdate obj)
        {
            var           CONNSTRING = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            SqlConnection conn       = new SqlConnection();

            conn.ConnectionString = CONNSTRING;



            if (new CreditNoteRMAHandler(CONNSTRING).GetRMAByCreditNoteIdAndSuppName(Convert.ToInt32(obj.CreId), obj.SuppName) == 0)
            {
                new CreditNotesDAL(CONNSTRING).WriteSupplierIntoRMA(obj.CreId, obj.SuppName);
            }

            var        rmaId   = new CreditNoteRMAHandler(CONNSTRING).GetRMAByCreditNoteIdAndSuppName(Convert.ToInt32(obj.CreId), obj.SuppName);
            var        RMAID   = rmaId.ToString();
            String     SqlStmt = @"UPDATE dbo.RMATracking SET SentToSupplier=@SentToSupplier, 
                      SentToSupplierDateTime=@SentToSupplierDateTime, ApprovedRMA=@ApprovedRMA, ApprovedRMADateTime=@ApprovedRMADateTime,
                      CreditInXero=@CreditInXero, CreditInXeroDateTime=@CreditInXeroDateTime, RMAToCustomer=@RMAToCustomer, 
                      RMAToCustomerDateTime=@RMAToCustomerDateTime, AdjustedNoteFromSupplier=@AdjustedNoteFromSupplier, 
                      AdjustedNoteFromSupplierDateTime=@AdjustedNoteFromSupplierDateTime, Status=@Status, SupplierRMANumber=@SupplierRMANumber, 
                TrackingNumber=@TrackingNumber , InHouse=@inHouse WHERE CreditNoteID =@crId AND SupplierName=@suppName";
            SqlCommand cmd     = new SqlCommand(SqlStmt, conn);

            cmd.Parameters.Add("@suppName", SqlDbType.NVarChar).Value = obj.SuppName;
            cmd.Parameters.Add("@crId", SqlDbType.Int).Value          = obj.CreId;
            String STS      = obj.STS;
            String STSWrite = String.Empty;

            //DateTime STSDateTime = new DateTime();
            if (STS == "True")
            {
                STSWrite = "1";
            }
            else
            {
                STSWrite = "0";
            }

            String inHouse      = obj.INHouse;
            String inHouseWrite = String.Empty;

            //DateTime STSDateTime = new DateTime();
            if (inHouse == "True")
            {
                inHouseWrite = "1";
            }
            else
            {
                inHouseWrite = "0";
            }

            cmd.Parameters.AddWithValue("@inHouse", inHouseWrite);

            String ARMA      = obj.ARMA;
            String ARMAWrite = String.Empty;

            if (ARMA == "True")
            {
                ARMAWrite = "1";
            }
            else
            {
                ARMAWrite = "0";
            }

            String CIX      = obj.CIX;
            String CIXWrite = String.Empty;

            if (CIX == "True")
            {
                CIXWrite = "1";
            }
            else
            {
                CIXWrite = "0";
            }

            String RTC      = obj.RTC;
            String RTCWrite = String.Empty;

            if (RTC == "True")
            {
                RTCWrite = "1";
            }
            else
            {
                RTCWrite = "0";
            }

            String ANFS      = obj.ANFS;
            String ANFSWrite = String.Empty;

            if (ANFS == "True")
            {
                ANFSWrite = "1";
            }
            else
            {
                ANFSWrite = "0";
            }

            String NewStatus = String.Empty;

            //if (STS == "True" && ARMA == "True" && CIX == "True" && RTC == "True" && ANFS == "True")
            //{
            //    NewStatus = "COMPLETED";
            //}
            //else
            //{

            //}
            NewStatus = new CreditNotesDAL(CONNSTRING).RMAStatusByCreditIdAndSuppllier(obj.CreId, obj.SuppName);

            if (inHouse == "True")
            {
                NewStatus = "COMPLETED";
            }
            else

            if (CIX == "True")
            {
                NewStatus = "COMPLETED";
            }


            cmd.Parameters.AddWithValue("@SentToSupplier", STSWrite);
            if (STS == "True")
            {
                if (checkIfSTSHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@SentToSupplierDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@SentToSupplierDateTime", DateTime.Parse(checkIfSTSHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@SentToSupplierDateTime", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@ApprovedRMA", ARMAWrite);

            if (ARMA == "True")
            {
                if (checkIfARMAHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@ApprovedRMADateTime", DateTime.Today);
                    //  sentRMATOCustomer(RMAID);  // sent email to customer once RMA Approved
                }
                else
                {
                    cmd.Parameters.AddWithValue("@ApprovedRMADateTime", DateTime.Parse(checkIfARMAHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@ApprovedRMADateTime", DBNull.Value);
            }


            cmd.Parameters.AddWithValue("@CreditInXero", CIXWrite);

            if (CIX == "True")
            {
                if (checkIfCIXHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@CreditInXeroDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@CreditInXeroDateTime", DateTime.Parse(checkIfCIXHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreditInXeroDateTime", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@RMAToCustomer", RTCWrite);

            if (RTC == "True")
            {
                if (checkIfRTCHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@RMAToCustomerDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@RMAToCustomerDateTime", DateTime.Parse(checkIfRTCHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@RMAToCustomerDateTime", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplier", ANFSWrite);

            if (ANFS == "True")
            {
                if (checkIfANFSHasValue(RMAID) == "")
                {
                    cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplierDateTime", DateTime.Today);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplierDateTime", DateTime.Parse(checkIfANFSHasValue(RMAID)));
                }
            }
            else
            {
                cmd.Parameters.AddWithValue("@AdjustedNoteFromSupplierDateTime", DBNull.Value);
            }
            cmd.Parameters.AddWithValue("@Status", NewStatus);

            cmd.Parameters.AddWithValue("@SupplierRMANumber", obj.SRMAN);

            cmd.Parameters.AddWithValue("@TrackingNumber", obj.TN);
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }