Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";
                if (txtSerie.Text == string.Empty)
                {
                    MessageError("Fill the fields");
                    //errorIcon.SetError(txtId, "Insert the supply");

                    errorIcon.SetError(txtSerie, "Insert the serie");
                }
                else
                {
                    if (this.isNew)
                    {
                        resp = BSale.Insert(Convert.ToInt32(this.txtidClient.Text), idstaff, Convert.ToDateTime(this.dtpDate.Text),
                                            this.cbReceipt.Text, txtSerie.Text, this.txtCorelativ.Text, this.txtVat.Text, dtDetails);
                    }


                    if (resp.Equals("OK"))
                    {
                        if (this.isNew)
                        {
                            this.MessageOk("Register saved");
                        }
                    }
                    else
                    {
                        this.MessageError(resp);
                    }

                    this.isNew = false;
                    this.Enabledbuttons();
                    this.Clean();
                    this.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #2
0
        private void btnCancelInput_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult option;
                option = MessageBox.Show("Do you really want to delete?", "SysBusiness", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (option == DialogResult.OK)
                {
                    string Code;
                    string resp = "";

                    foreach (DataGridViewRow row in dataList.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Code = Convert.ToString(row.Cells[1].Value);
                            resp = BSale.Delete(Convert.ToInt32(Code));

                            if (resp.Equals("OK"))
                            {
                                this.MessageOk("Success deleted");
                            }
                            else
                            {
                                this.MessageError(resp);
                            }
                        }
                    }
                    this.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        private List <BSale> SyncTrades(DateTime?sDate, DateTime?eDate, string status, long page, out long totalTrades, out bool hasNextPage, bool onlyReFound = false)
        {
            totalTrades = 0;
            hasNextPage = false;
            TradesSoldGetRequest req = new TradesSoldGetRequest();

            req.Fields  = "total_fee,buyer_nick,created,tid,status, payment, discount_fee, adjust_fee, post_fee,price,adjust_fee,receiver_city,receiver_district,receiver_name,receiver_state,receiver_mobile,receiver_phone,received_payment";
            req.Fields += ",orders.title,orders.pic_path,orders.price,orders.num,orders.iid,orders.num_iid,orders.sku_id,orders.refund_status,orders.status,orders.oid,orders.total_fee,orders.payment,orders.discount_fee,orders.adjust_fee,orders.sku_properties_name,orders.item_meal_name,orders.buyer_rate,orders.seller_rate,orders.outer_iid,orders.outer_sku_id,orders.refund_id,orders.seller_type";

            if (sDate != null)
            {
                req.StartCreated = sDate;
            }

            if (eDate != null)
            {
                req.EndCreated = eDate;
            }

            if (!string.IsNullOrEmpty(status))
            {
                req.Status = status;
            }
            //req.BuyerNick = "zhangsan";
            //req.Type = "game_equipment";
            //req.ExtType = "service";
            //req.RateStatus = "RATE_UNBUYER";
            //req.Tag = "time_card";
            req.PageNo     = page;
            req.PageSize   = 50L;
            req.UseHasNext = true;
            TradesSoldGetResponse response = client.Execute(req, this.Access_Token.Access_Token1);

            List <BSale> sales = new List <BSale>();

            if (response.IsError)
            {
                throw new KMJXCTaobaoException(response.ErrCode, response.SubErrMsg);
            }

            if (response.Trades != null)
            {
                hasNextPage = response.HasNext;
                totalTrades = response.TotalResults;
                foreach (TB.Trade trade in response.Trades)
                {
                    if (trade.Tid <= 0)
                    {
                        continue;
                    }
                    var existedSales = from esale in sales where esale.Sale_ID == trade.Tid.ToString() select esale;
                    if (existedSales.Count() > 0)
                    {
                        continue;
                    }

                    bool  containRefound = false;
                    BSale sale           = new BSale();
                    sale.Status       = trade.Status;
                    sale.SaleDateTime = DateTimeUtil.ConvertDateTimeToInt(Convert.ToDateTime(trade.Created));
                    sale.Sale_ID      = trade.Tid.ToString();
                    sale.Orders       = new List <BOrder>();
                    sale.Synced       = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                    if (!string.IsNullOrEmpty(trade.PostFee))
                    {
                        sale.Post_Fee = double.Parse(trade.PostFee);
                    }
                    if (!string.IsNullOrEmpty(trade.Payment))
                    {
                        sale.Amount = double.Parse(trade.Payment);
                    }

                    sale.Province = new Common_District()
                    {
                        name = trade.ReceiverState
                    };
                    sale.City = new Common_District()
                    {
                        name = trade.ReceiverState
                    };
                    sale.Buyer = new BCustomer()
                    {
                        Type = new BMallType()
                        {
                            ID = this.Mall_Type_ID
                        }, Mall_ID = trade.BuyerNick, Name = trade.ReceiverName, Address = trade.ReceiverAddress, Phone = trade.ReceiverMobile, Province = new Common_District {
                            name = trade.ReceiverState
                        }, City = new Common_District()
                        {
                            name = trade.ReceiverCity
                        }
                    };
                    if (trade.Orders != null)
                    {
                        foreach (TB.Order o in trade.Orders)
                        {
                            if (o.Oid <= 0)
                            {
                                continue;
                            }

                            var existedOrders = from so in sale.Orders where so.Order_ID == o.Oid.ToString() select so;
                            if (existedOrders.Count() > 0)
                            {
                                continue;
                            }

                            //if (string.IsNullOrEmpty(o.OuterIid))
                            //{
                            //    continue;
                            //}
                            BOrder order = new BOrder();
                            if (!string.IsNullOrEmpty(o.Title))
                            {
                                order.Title = o.Title;
                            }

                            if (!string.IsNullOrEmpty(o.Payment))
                            {
                                order.Amount = double.Parse(o.Payment);
                            }

                            if (!string.IsNullOrEmpty(o.Price))
                            {
                                order.Price = double.Parse(o.Price);
                            }

                            order.Quantity = int.Parse(o.Num.ToString());
                            order.Status   = o.Status;
                            order.Status1  = 0;
                            if (!string.IsNullOrEmpty(o.RefundStatus) && o.RefundStatus == "SUCCESS")
                            {
                                containRefound = true;
                                order.Refound  = true;
                                sale.Amount    = sale.Amount - order.Amount;
                            }
                            order.StockStatus = 0;
                            order.Discount    = string.IsNullOrEmpty(o.DiscountFee) ? double.Parse(o.DiscountFee) : 0;
                            order.Order_ID    = o.Oid.ToString();
                            order.Mall_PID    = o.NumIid.ToString();

                            if (!string.IsNullOrEmpty(o.OuterIid))
                            {
                                int pid = 0;
                                int.TryParse(o.OuterIid, out pid);
                                order.Parent_Product_ID = pid;

                                if (!string.IsNullOrEmpty(o.SkuId))
                                {
                                    int pcid = 0;
                                    int.TryParse(o.OuterSkuId, out pcid);
                                    order.Product_ID = pcid;
                                    order.Mall_SkuID = o.SkuId;
                                }
                                else
                                {
                                    order.Mall_SkuID = "";
                                    order.Product_ID = order.Parent_Product_ID;
                                }
                            }
                            order.ImageUrl = "";
                            if (!string.IsNullOrEmpty(o.PicPath))
                            {
                                order.ImageUrl = o.PicPath;
                            }

                            sale.Orders.Add(order);
                        }
                    }

                    sale.HasRefound = containRefound;

                    if (onlyReFound)
                    {
                        if (containRefound)
                        {
                            sales.Add(sale);
                        }
                    }
                    else
                    {
                        sales.Add(sale);
                    }
                }
            }
            return(sales);
        }
Example #4
0
 //Show details sale
 private void ShowDetailSale()
 {
     this.dataListDetails.DataSource = BSale.ShowDetailsSale(this.txtId.Text);
 }
Example #5
0
 private void ShowDate()
 {
     this.dataList.DataSource = BSale.SearchNameDate(this.dtpInitialDate.Value.ToString("yyyy/MM/dd"), this.dtpFinalDate.Value.ToString("yyyy/MM/dd"));
     this.HideCollumns();
     lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found";
 }
Example #6
0
 private void Show()
 {
     this.dataList.DataSource = BSale.Show();
     this.HideCollumns();
     lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found";
 }
Example #7
0
 private void ShowProduct_Sale_Code() //show products by code
 {
     this.dataList.DataSource = BSale.ShowProduct_Sale_Code(this.txtSearch.Text);
     this.HideCollumns();
     lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found";
 }