/// <summary> /// ��ѯ4��֮�ڵķּ� /// </summary> /// <returns></returns> public DataTable GetOrderId(string orderDate) { using (PersistentManager dbpm = new PersistentManager()) { DownSortingOrderDao dao = new DownSortingOrderDao(); return dao.GetOrderId(orderDate); } }
/// <summary> /// �����û�ѡ��Ķ������طּ��߶������� /// </summary> /// <returns></returns> public DataTable GetSortingOrder(string orderid) { using (PersistentManager dbpm = new PersistentManager("YXConnection")) { DownSortingOrderDao dao = new DownSortingOrderDao(); dao.SetPersistentManager(dbpm); return dao.GetSortingOrder(orderid); } }
/// <summary> /// ѡ�����ڴ�Ӫ��ϵͳ���طּ���Ϣ /// </summary> /// <param name="orderDate"></param> /// <param name="endDate"></param> /// <returns></returns> public bool GetSortingOrderDate(string orderDate, string endDate, out string errorInfo) { bool tag = false; errorInfo=string.Empty; using (PersistentManager dbpm = new PersistentManager()) { DownSortingOrderDao dao = new DownSortingOrderDao(); try { //��ѯ�ֿ�7���ڵĶ����� DataTable orderdt = this.GetOrderId(orderDate); string orderlist = UtinString.MakeString(orderdt, "order_id"); string orderlistDate = "ORDER_DATE ='" + orderDate + "'"; DataTable masterdt = this.GetSortingOrder(orderlistDate);//����ʱ���ѯ�������� DataRow[] masterdr = masterdt.Select("ORDERID NOT IN(" + orderlist + ")");//�ų��Ѿ����ص����� string ordermasterlist = UtinString.MakeString(masterdr, "ORDERID");//��ȡδ����������ݵ������ַ� DataTable detaildt = this.GetSortingOrderDetail(orderlistDate);//����ʱ���ѯϸ������ DataRow[] detaildr = detaildt.Select("ORDERID IN (" + ordermasterlist + ")");//��ѯδ���ص�ϸ������ if (masterdr.Length > 0 && detaildr.Length > 0) { DataSet masterds = this.SaveSortingOrder(masterdr); DataSet detailds = this.SaveSortingOrderDetail(detaildr); this.Insert(masterds, detailds); //�ϱ��ּ� //upload.uploadSort(masterds, detailds); tag = true; } else errorInfo= "û�п��õ��������أ�"; } catch (Exception e) { errorInfo = "���طּ�����ʧ�ܣ�ԭ��" + e.Message; } } return tag; }
/// <summary> /// ѡ�����ڴ�Ӫ��ϵͳ���طּ���Ϣ /// </summary> /// <param name="orderDate"></param> /// <param name="endDate"></param> /// <returns></returns> public bool GetSortingOrderDate(string orderDate, string endDate, out string errorInfo) { bool tag = false; errorInfo=string.Empty; using (PersistentManager dbpm = new PersistentManager()) { DownSortingOrderDao dao = new DownSortingOrderDao(); try { //��ѯ�ֿ�7���ڵĶ����� DataTable orderdt = this.GetOrderId(orderDate); string orderlist = UtinString.MakeString(orderdt, "order_id"); string orderlistDate = "ORDER_DATE ='" + orderDate + "' AND ORDER_ID NOT IN(" + orderlist + ")"; DataTable masterdt = this.GetSortingOrder(orderlistDate);//����ʱ���ѯ������Ϣ string ordermasterlist = UtinString.MakeString(masterdt, "ORDER_ID");//ȡ�ø���ʱ���ѯ�Ķ����� ordermasterlist = "ORDER_ID IN (" + ordermasterlist + ")"; DataTable detaildt = this.GetSortingOrderDetail(ordermasterlist);//���ݶ����Ų�ѯ��ϸ if (masterdt.Rows.Count > 0 && detaildt.Rows.Count > 0) { DataSet masterds = this.SaveSortingOrder(masterdt); DataSet detailds = this.SaveSortingOrderDetail(detaildt); this.Insert(masterds, detailds); //�ϱ��ּ� //upload.uploadSort(masterds, detailds); tag = true; } else errorInfo= "û�п��õ��������أ�"; } catch (Exception e) { errorInfo = "���طּ�����ʧ�ܣ�ԭ��" + e.Message; } } return tag; }
/// <summary> /// ���涩����ϸ������������ /// </summary> /// <param name="dr"></param> /// <returns></returns> public DataSet SaveSortingOrderDetails(DataTable detaildt) { DownSortingOrderDao dao = new DownSortingOrderDao(); DataTable unitList = dao.GetUnitProduct(); DataSet ds = this.GenerateEmptyTables(); try { int i = 0; foreach (DataRow row in detaildt.Rows) { DataRow detailrow = ds.Tables["DWV_OUT_ORDER_DETAIL"].NewRow(); i++; detailrow["order_detail_id"] = row["ORDER_DETAIL_ID"].ToString().Trim() + i; detailrow["order_id"] = row["ORDER_ID"].ToString().Trim(); detailrow["product_code"] = row["BRAND_CODE"].ToString().Trim(); detailrow["product_name"] = row["BRAND_NAME"].ToString().Trim(); detailrow["unit_code"] = row["BRAND_UNIT_CODE"].ToString(); detailrow["unit_name"] = row["BRAND_UNIT_NAME"].ToString().Trim(); ; detailrow["demand_quantity"] = Convert.ToDecimal(row["QUANTITY"]); detailrow["real_quantity"] = Convert.ToDecimal(row["QUANTITY"]); detailrow["price"] = Convert.ToDecimal(row["PRICE"]); detailrow["amount"] = Convert.ToDecimal(row["AMOUNT"]); detailrow["unit_quantity"] = 50; ds.Tables["DWV_OUT_ORDER_DETAIL"].Rows.Add(detailrow); } return ds; } catch (Exception e) { string s = e.Message; return null; } }
/// <summary> /// ���涩����ϸ������������DataTable /// </summary> /// <param name="dr"></param> /// <returns></returns> public DataSet SaveSortingOrderDetail(DataRow[] detaildt) { DownSortingOrderDao dao = new DownSortingOrderDao(); DataTable unitList = dao.GetUnitProduct(); DataSet ds = this.GenerateEmptyTables(); try { int i = 0; foreach (DataRow row in detaildt) { DataRow[] list = unitList.Select(string.Format("unit_list_code='{0}'", row["BRANDCODE"].ToString().Trim())); DataRow detailrow = ds.Tables["DWV_OUT_ORDER_DETAIL"].NewRow(); i++; string newcode = i.ToString(); for (int j = 0; j < 5 - i.ToString().Length; j++) { newcode = "0" + newcode; } detailrow["order_detail_id"] = row["ORDER_DETAIL_ID"].ToString().Trim() + newcode; detailrow["order_id"] = row["ORDERID"].ToString().Trim(); detailrow["product_code"] = row["BRANDCODE"].ToString().Trim(); detailrow["product_name"] = row["BRAND_NAME"].ToString().Trim(); detailrow["unit_code"] = list[0]["unit_code02"].ToString(); detailrow["unit_name"] = row["BRAND_UNIT_NAME"].ToString().Trim(); ; detailrow["demand_quantity"] = Convert.ToDecimal(row["QUANTITY"]); detailrow["real_quantity"] = Convert.ToDecimal(row["QUANTITY"]); detailrow["price"] = Convert.ToDecimal(row["PRICE"]); detailrow["amount"] = Convert.ToDecimal(row["AMOUNT"]); detailrow["unit_quantity"] = 50; ds.Tables["DWV_OUT_ORDER_DETAIL"].Rows.Add(detailrow); } return ds; } catch (Exception e) { string s = e.Message; return null; } }
/// <summary> /// �����ص�������ӵ����ݿ⡣ /// </summary> /// <param name="masterds"></param> /// <param name="detailds"></param> public void Insert(DataSet masterds, DataSet detailds) { using (PersistentManager pm = new PersistentManager()) { DownSortingOrderDao dao = new DownSortingOrderDao(); if (masterds.Tables["DWV_OUT_ORDER"].Rows.Count > 0) { dao.InsertSortingOrder(masterds); } if (detailds.Tables["DWV_OUT_ORDER_DETAIL"].Rows.Count > 0) { dao.InsertSortingOrderDetail(detailds); } } }